Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(512)

Side by Side Diff: blimp/engine/app/blimp_content_main_delegate.cc

Issue 1929723002: [Blimp] Adds blimp engine browser test framework and LoadUrl test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix listening port allocation issue Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "blimp/engine/app/blimp_content_main_delegate.h" 5 #include "blimp/engine/app/blimp_content_main_delegate.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file.h" 8 #include "base/files/file.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "blimp/engine/app/blimp_content_browser_client.h" 12 #include "blimp/engine/app/blimp_content_browser_client.h"
13 #include "blimp/engine/renderer/blimp_content_renderer_client.h" 13 #include "blimp/engine/renderer/blimp_content_renderer_client.h"
14 #include "mojo/public/cpp/bindings/interface_request.h" 14 #include "mojo/public/cpp/bindings/interface_request.h"
15 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
16 16
17 namespace blimp { 17 namespace blimp {
18 namespace engine { 18 namespace engine {
19 namespace { 19 namespace {
20
21 BlimpContentMainDelegate* g_content_main_delegate = nullptr;
22
20 void InitLogging() { 23 void InitLogging() {
21 // TODO(haibinlu): Remove this before release. 24 // TODO(haibinlu): Remove this before release.
22 // Enables a few verbose log by default. 25 // Enables a few verbose log by default.
23 if (!base::CommandLine::ForCurrentProcess()->HasSwitch("vmodule")) { 26 if (!base::CommandLine::ForCurrentProcess()->HasSwitch("vmodule")) {
24 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( 27 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
25 "vmodule", "remote_channel_main=1"); 28 "vmodule", "remote_channel_main=1");
26 } 29 }
27 30
28 logging::LoggingSettings settings; 31 logging::LoggingSettings settings;
29 base::FilePath log_filename; 32 base::FilePath log_filename;
30 PathService::Get(base::DIR_EXE, &log_filename); 33 PathService::Get(base::DIR_EXE, &log_filename);
31 log_filename = log_filename.AppendASCII("blimp_engine.log"); 34 log_filename = log_filename.AppendASCII("blimp_engine.log");
32 settings.logging_dest = logging::LOG_TO_ALL; 35 settings.logging_dest = logging::LOG_TO_ALL;
33 settings.log_file = log_filename.value().c_str(); 36 settings.log_file = log_filename.value().c_str();
34 settings.delete_old = logging::DELETE_OLD_LOG_FILE; 37 settings.delete_old = logging::DELETE_OLD_LOG_FILE;
35 logging::InitLogging(settings); 38 logging::InitLogging(settings);
36 logging::SetLogItems(true, // Process ID 39 logging::SetLogItems(true, // Process ID
37 true, // Thread ID 40 true, // Thread ID
38 true, // Timestamp 41 true, // Timestamp
39 false); // Tick count 42 false); // Tick count
40 } 43 }
41 } // namespace 44 } // namespace
42 45
43 BlimpContentMainDelegate::BlimpContentMainDelegate() {} 46 BlimpContentMainDelegate::BlimpContentMainDelegate() {
47 DCHECK(!g_content_main_delegate);
48 g_content_main_delegate = this;
49 }
44 50
45 BlimpContentMainDelegate::~BlimpContentMainDelegate() {} 51 BlimpContentMainDelegate::~BlimpContentMainDelegate() {
52 DCHECK_EQ(this, g_content_main_delegate);
53 g_content_main_delegate = nullptr;
54 }
55
56 BlimpContentBrowserClient*
57 BlimpContentMainDelegate::GetBlimpContentBrowserClient() {
58 return browser_client_.get();
59 }
46 60
47 bool BlimpContentMainDelegate::BasicStartupComplete(int* exit_code) { 61 bool BlimpContentMainDelegate::BasicStartupComplete(int* exit_code) {
48 InitLogging(); 62 InitLogging();
49 content::SetContentClient(&content_client_); 63 content::SetContentClient(&content_client_);
50 return false; 64 return false;
51 } 65 }
52 66
53 void BlimpContentMainDelegate::PreSandboxStartup() { 67 void BlimpContentMainDelegate::PreSandboxStartup() {
54 InitializeResourceBundle(); 68 InitializeResourceBundle();
55 } 69 }
56 70
71 // static
72 BlimpContentMainDelegate* BlimpContentMainDelegate::GetInstanceForTesting() {
73 return g_content_main_delegate;
74 }
75
57 void BlimpContentMainDelegate::InitializeResourceBundle() { 76 void BlimpContentMainDelegate::InitializeResourceBundle() {
58 base::FilePath pak_file; 77 base::FilePath pak_file;
59 bool pak_file_valid = PathService::Get(base::DIR_MODULE, &pak_file); 78 bool pak_file_valid = PathService::Get(base::DIR_MODULE, &pak_file);
60 CHECK(pak_file_valid); 79 CHECK(pak_file_valid);
61 pak_file = pak_file.Append(FILE_PATH_LITERAL("blimp_engine.pak")); 80 pak_file = pak_file.Append(FILE_PATH_LITERAL("blimp_engine.pak"));
62 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file); 81 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file);
63 } 82 }
64 83
65 content::ContentBrowserClient* 84 content::ContentBrowserClient*
66 BlimpContentMainDelegate::CreateContentBrowserClient() { 85 BlimpContentMainDelegate::CreateContentBrowserClient() {
67 DCHECK(!browser_client_); 86 DCHECK(!browser_client_);
68 browser_client_.reset(new BlimpContentBrowserClient); 87 browser_client_.reset(new BlimpContentBrowserClient);
69 return browser_client_.get(); 88 return browser_client_.get();
70 } 89 }
71 90
72 content::ContentRendererClient* 91 content::ContentRendererClient*
73 BlimpContentMainDelegate::CreateContentRendererClient() { 92 BlimpContentMainDelegate::CreateContentRendererClient() {
74 DCHECK(!renderer_client_); 93 DCHECK(!renderer_client_);
75 renderer_client_.reset(new BlimpContentRendererClient); 94 renderer_client_.reset(new BlimpContentRendererClient);
76 return renderer_client_.get(); 95 return renderer_client_.get();
77 } 96 }
78 97
79 } // namespace engine 98 } // namespace engine
80 } // namespace blimp 99 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698