If you're following the example exactly , you created a math_service.mojom file in the .../chrome/services/math/public/mojom directory, not in .../chrome/credential_provider. If you actually put the file somewhere in the .../chrome/credential_provider, you need to change all the paths in the example to where you actually put math_services.mojom.
Assuming you put the example code in chrome/services/math, and you want to USE the services in .../chrome/credential_provider (using that code you pasted), there are two BUILD.gn files involved:
# src/chrome/services/math/public/mojom/BUILD.gn
import("//mojo/public/tools/bindings/mojom.gni")
mojom("mojom") {
sources = [
"math_service.mojom",
]
}
That defines a target called "//chrome/services/math/public/mojom:mojom" that generates math_service.mojom.h and some other files from math_service.mojom. (It can also just be "//chrome/services/math/public/mojom" for short, since the target name ":mojom" matches the directory name.)
And whatever .cc file you're putting that "math_service = ..." line in should be in a BUILD.gn file in credential_provider. For instance if you're adding it to chrome/credential_provider/test/gcp_setup_unittest.cc, I see that file in the
"gcp_unittests" target of chrome/credential_provider/test/BUILD.gn. So you need to tell the build system that target now depends on "//chrome/services/math/public/mojom:mojom" to make sure it builds it first, by adding it to the "deps" list:
deps = [
"../extension:app_inventory",
"../extension:common",
...
"//chrome/common:version_header",
"//chrome/services/math/public/mojom:mojom", <-- Add this.
"//content/public/browser",