Skip to content

Commit

Permalink
[fuchsia] Move SetAPIKey call to WebEngineMainDelegate::BasicStartupC…
Browse files Browse the repository at this point in the history
…omplete()

In https://crrev.com/c/2613649, a call to google_apis::SetAPIKey() was
added in the main() function. However, there is no AtExitManager
registered by that point, resulting in a crash in builds with dchecks
enabled. This moves the call to google_apis::SetAPIKey() to be done in
WebEngineMainDelegate::BasicStartupComplete() instead.

Bug: 1168325
Change-Id: Iee034fb20c7d4d8563cbd9973943d87339619b71
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2638634
Commit-Queue: Fabrice de Gans-Riberi <fdegans@chromium.org>
Reviewed-by: Sharon Yang <yangsharon@chromium.org>
Reviewed-by: David Dorwin <ddorwin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#845004}
  • Loading branch information
Steelskin authored and Chromium LUCI CQ committed Jan 20, 2021
1 parent bd19f4a commit c3ad19a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
3 changes: 1 addition & 2 deletions fuchsia/engine/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ component("web_engine_core") {
"//fuchsia/base:message_port",
"//fuchsia/base:modular",
"//fuchsia/cast_streaming",
"//google_apis",
"//gpu/command_buffer/service",
"//media",
"//media/fuchsia/cdm/service",
Expand Down Expand Up @@ -258,11 +259,9 @@ source_set("switches") {

executable("web_engine_exe") {
deps = [
":switches",
":web_engine_core",
"//base",
"//content/public/app",
"//google_apis",
]
sources = [ "web_engine_main.cc" ]
visibility = [ ":*" ]
Expand Down
11 changes: 2 additions & 9 deletions fuchsia/engine/web_engine_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@
#include "content/public/common/content_switches.h"
#include "fuchsia/engine/context_provider_impl.h"
#include "fuchsia/engine/context_provider_main.h"
#include "fuchsia/engine/switches.h"
#include "fuchsia/engine/web_engine_main_delegate.h"
#include "google_apis/google_api_keys.h"

int main(int argc, const char** argv) {
base::CommandLine::Init(argc, argv);
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();

std::string process_type =
command_line->GetSwitchValueASCII(switches::kProcessType);
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kProcessType);
fidl::InterfaceRequest<fuchsia::web::Context> context;

if (process_type.empty()) {
Expand All @@ -43,10 +41,5 @@ int main(int argc, const char** argv) {
params.argc = 0;
params.argv = nullptr;

if (command_line->HasSwitch(switches::kGoogleApiKey)) {
google_apis::SetAPIKey(
command_line->GetSwitchValueASCII(switches::kGoogleApiKey));
}

return content::ContentMain(params);
}
6 changes: 6 additions & 0 deletions fuchsia/engine/web_engine_main_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "fuchsia/engine/common/web_engine_content_client.h"
#include "fuchsia/engine/renderer/web_engine_content_renderer_client.h"
#include "fuchsia/engine/switches.h"
#include "google_apis/google_api_keys.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h"

Expand Down Expand Up @@ -86,6 +87,11 @@ bool WebEngineMainDelegate::BasicStartupComplete(int* exit_code) {
return true;
}

if (command_line->HasSwitch(switches::kGoogleApiKey)) {
google_apis::SetAPIKey(
command_line->GetSwitchValueASCII(switches::kGoogleApiKey));
}

SetCorsExemptHeaders(base::SplitString(
base::CommandLine::ForCurrentProcess()->GetSwitchValueNative(
switches::kCorsExemptHeaders),
Expand Down

0 comments on commit c3ad19a

Please sign in to comment.