Acting U.S. Secretary of Defense Patrick M. Shanahan and Marine Corps Gen. Joe Dunford, chairman of the Joint Chiefs of Staff, give testimony on the Department of Defense budget posture in review of the Defense Authorization Request for Fiscal Year 2020 and the Future Years Defense Program at the Dirksen Senate Office Building, March 14, 2019.

WASHINGTON — America's top two defense officials slammed Google's work with China on Thursday saying it has "indirectly benefited" Beijing's military.

"We watch with great concern when industry partners work in China knowing that there is that indirect benefit," Marine Corps Gen. Joseph Dunford, chairman of the Joint Chiefs of Staff, told members of the Senate Armed Services Committee hearing.

"The work that Google is doing in China is indirectly benefiting the Chinese military," Dunford said. "The way I describe it to industry partners is, 'look we're the good guys and the values that we represent and the system we represent is the one that will allow and has allowed you to thrive,'" he said.

Dunford's comments come in the wake of the tech giants' decision not to pursue some of the Pentagon's lucrative contracts while considering projects in China.

In October, Google said it would no longer compete for the Pentagon's Joint Enterprise Defense Infrastructure, or JEDI, cloud computing contract, an award that could be worth $10 billion. Google said that the contract may conflict with its corporate values. In addition, the company also said it would not renew a Pentagon contract that analyzed aerial drone imagery for the military.

Meanwhile, it was revealed last year that the tech giant was studying the idea of working with the Chinese government on "Project Dragonfly," a censored search engine that would block certain sites and search terms. More recently, after pushback from politicians and activists, Google said it had dropped those plans.

Read more: Senator slams Google's censored search engine work in China

But Google Chief Executive Sundar Pichai has said the company will continue to invest in China while also considering projects with the U.S. government.

Acting Secretary of Defense Patrick Shanahan, also speaking before the Senate committee, echoed concerns that China has gamed American innovation.

"$5 trillion of their [China's] economy is state-owned enterprises. So the technology that has developed in the civil world transfers to the military world, it's a direct pipeline. Not only is there a transfer, there is systemic theft of U.S. technology that facilitates even faster development of emerging technology," he said.

"The talent is in this country, we need to use the talent in this country and the talent in this country needs to support our great power competition," Shanahan added.

The criticism comes as the U.S. trade battle with China marches on, with intellectual property theft proving to be a major sticking point between the world's two largest economies.

U.S. officials have long complained that intellectual property theft has cost the economy billions of dollars in revenue, thousands of jobs and threatens national security.

"If China successfully captures these emerging industries of the future, America will have no economic future and its national security will be severely compromised," White House trade advisor Peter Navarro said in June.

For the Pentagon, there is no better example of Navarro's comments than the most expensive U.S. weapons system: the F-35 Joint Strike Fighter.