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

Side by Side Diff: headless/lib/headless_content_main_delegate.cc

Issue 1854043002: convert //headless to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 "headless/lib/headless_content_main_delegate.h" 5 #include "headless/lib/headless_content_main_delegate.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
11 #include "content/public/browser/browser_main_runner.h" 11 #include "content/public/browser/browser_main_runner.h"
12 #include "content/public/common/content_switches.h" 12 #include "content/public/common/content_switches.h"
13 #include "headless/lib/browser/headless_browser_impl.h" 13 #include "headless/lib/browser/headless_browser_impl.h"
14 #include "headless/lib/browser/headless_content_browser_client.h" 14 #include "headless/lib/browser/headless_content_browser_client.h"
15 #include "headless/lib/renderer/headless_content_renderer_client.h" 15 #include "headless/lib/renderer/headless_content_renderer_client.h"
16 #include "headless/lib/utility/headless_content_utility_client.h" 16 #include "headless/lib/utility/headless_content_utility_client.h"
17 #include "ui/base/resource/resource_bundle.h" 17 #include "ui/base/resource/resource_bundle.h"
18 #include "ui/ozone/public/ozone_switches.h" 18 #include "ui/ozone/public/ozone_switches.h"
19 19
20 namespace headless { 20 namespace headless {
21 namespace { 21 namespace {
22 // Keep in sync with content/common/content_constants_internal.h. 22 // Keep in sync with content/common/content_constants_internal.h.
23 // TODO(skyostil): Add a tracing test for this. 23 // TODO(skyostil): Add a tracing test for this.
24 const int kTraceEventBrowserProcessSortIndex = -6; 24 const int kTraceEventBrowserProcessSortIndex = -6;
25 25
26 HeadlessContentMainDelegate* g_current_headless_content_main_delegate = nullptr; 26 HeadlessContentMainDelegate* g_current_headless_content_main_delegate = nullptr;
27 } // namespace 27 } // namespace
28 28
29 HeadlessContentMainDelegate::HeadlessContentMainDelegate( 29 HeadlessContentMainDelegate::HeadlessContentMainDelegate(
30 scoped_ptr<HeadlessBrowserImpl> browser) 30 std::unique_ptr<HeadlessBrowserImpl> browser)
31 : content_client_(browser->options()), browser_(std::move(browser)) { 31 : content_client_(browser->options()), browser_(std::move(browser)) {
32 DCHECK(!g_current_headless_content_main_delegate); 32 DCHECK(!g_current_headless_content_main_delegate);
33 g_current_headless_content_main_delegate = this; 33 g_current_headless_content_main_delegate = this;
34 } 34 }
35 35
36 HeadlessContentMainDelegate::~HeadlessContentMainDelegate() { 36 HeadlessContentMainDelegate::~HeadlessContentMainDelegate() {
37 DCHECK(g_current_headless_content_main_delegate == this); 37 DCHECK(g_current_headless_content_main_delegate == this);
38 g_current_headless_content_main_delegate = nullptr; 38 g_current_headless_content_main_delegate = nullptr;
39 } 39 }
40 40
(...skipping 21 matching lines...) Expand all
62 int HeadlessContentMainDelegate::RunProcess( 62 int HeadlessContentMainDelegate::RunProcess(
63 const std::string& process_type, 63 const std::string& process_type,
64 const content::MainFunctionParams& main_function_params) { 64 const content::MainFunctionParams& main_function_params) {
65 if (!process_type.empty()) 65 if (!process_type.empty())
66 return -1; 66 return -1;
67 67
68 base::trace_event::TraceLog::GetInstance()->SetProcessName("HeadlessBrowser"); 68 base::trace_event::TraceLog::GetInstance()->SetProcessName("HeadlessBrowser");
69 base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex( 69 base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex(
70 kTraceEventBrowserProcessSortIndex); 70 kTraceEventBrowserProcessSortIndex);
71 71
72 scoped_ptr<content::BrowserMainRunner> browser_runner( 72 std::unique_ptr<content::BrowserMainRunner> browser_runner(
73 content::BrowserMainRunner::Create()); 73 content::BrowserMainRunner::Create());
74 74
75 int exit_code = browser_runner->Initialize(main_function_params); 75 int exit_code = browser_runner->Initialize(main_function_params);
76 DCHECK_LT(exit_code, 0) << "content::BrowserMainRunner::Initialize failed in " 76 DCHECK_LT(exit_code, 0) << "content::BrowserMainRunner::Initialize failed in "
77 "HeadlessContentMainDelegate::RunProcess"; 77 "HeadlessContentMainDelegate::RunProcess";
78 78
79 browser_->RunOnStartCallback(); 79 browser_->RunOnStartCallback();
80 browser_runner->Run(); 80 browser_runner->Run();
81 browser_.reset(); 81 browser_.reset();
82 browser_runner->Shutdown(); 82 browser_runner->Shutdown();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 return renderer_client_.get(); 115 return renderer_client_.get();
116 } 116 }
117 117
118 content::ContentUtilityClient* 118 content::ContentUtilityClient*
119 HeadlessContentMainDelegate::CreateContentUtilityClient() { 119 HeadlessContentMainDelegate::CreateContentUtilityClient() {
120 utility_client_.reset(new HeadlessContentUtilityClient); 120 utility_client_.reset(new HeadlessContentUtilityClient);
121 return utility_client_.get(); 121 return utility_client_.get();
122 } 122 }
123 123
124 } // namespace headless 124 } // namespace headless
OLDNEW
« no previous file with comments | « headless/lib/headless_content_main_delegate.h ('k') | headless/lib/headless_web_contents_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698