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

Side by Side Diff: headless/lib/browser/headless_browser_impl.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/browser/headless_browser_impl.h" 5 #include "headless/lib/browser/headless_browser_impl.h"
6 6
7 #include "base/memory/ptr_util.h"
7 #include "base/thread_task_runner_handle.h" 8 #include "base/thread_task_runner_handle.h"
8 #include "content/public/app/content_main.h" 9 #include "content/public/app/content_main.h"
9 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
10 #include "content/public/browser/web_contents.h" 11 #include "content/public/browser/web_contents.h"
11 #include "headless/lib/browser/headless_browser_context.h" 12 #include "headless/lib/browser/headless_browser_context.h"
12 #include "headless/lib/browser/headless_browser_main_parts.h" 13 #include "headless/lib/browser/headless_browser_main_parts.h"
13 #include "headless/lib/browser/headless_web_contents_impl.h" 14 #include "headless/lib/browser/headless_web_contents_impl.h"
14 #include "headless/lib/headless_content_main_delegate.h" 15 #include "headless/lib/headless_content_main_delegate.h"
15 #include "ui/aura/env.h" 16 #include "ui/aura/env.h"
16 #include "ui/aura/window_tree_host.h" 17 #include "ui/aura/window_tree_host.h"
17 #include "ui/gfx/geometry/size.h" 18 #include "ui/gfx/geometry/size.h"
18 19
19 namespace headless { 20 namespace headless {
20 21
21 HeadlessBrowserImpl::HeadlessBrowserImpl( 22 HeadlessBrowserImpl::HeadlessBrowserImpl(
22 const base::Callback<void(HeadlessBrowser*)>& on_start_callback, 23 const base::Callback<void(HeadlessBrowser*)>& on_start_callback,
23 const HeadlessBrowser::Options& options) 24 const HeadlessBrowser::Options& options)
24 : on_start_callback_(on_start_callback), 25 : on_start_callback_(on_start_callback),
25 options_(options), 26 options_(options),
26 browser_main_parts_(nullptr) { 27 browser_main_parts_(nullptr) {
27 DCHECK(!on_start_callback_.is_null()); 28 DCHECK(!on_start_callback_.is_null());
28 } 29 }
29 30
30 HeadlessBrowserImpl::~HeadlessBrowserImpl() {} 31 HeadlessBrowserImpl::~HeadlessBrowserImpl() {}
31 32
32 scoped_ptr<HeadlessWebContents> HeadlessBrowserImpl::CreateWebContents( 33 std::unique_ptr<HeadlessWebContents> HeadlessBrowserImpl::CreateWebContents(
33 const gfx::Size& size) { 34 const gfx::Size& size) {
34 DCHECK(BrowserMainThread()->BelongsToCurrentThread()); 35 DCHECK(BrowserMainThread()->BelongsToCurrentThread());
35 return make_scoped_ptr(new HeadlessWebContentsImpl( 36 return base::WrapUnique(new HeadlessWebContentsImpl(
36 browser_context(), window_tree_host_->window(), size)); 37 browser_context(), window_tree_host_->window(), size));
37 } 38 }
38 39
39 scoped_refptr<base::SingleThreadTaskRunner> 40 scoped_refptr<base::SingleThreadTaskRunner>
40 HeadlessBrowserImpl::BrowserMainThread() const { 41 HeadlessBrowserImpl::BrowserMainThread() const {
41 return content::BrowserThread::GetMessageLoopProxyForThread( 42 return content::BrowserThread::GetMessageLoopProxyForThread(
42 content::BrowserThread::UI); 43 content::BrowserThread::UI);
43 } 44 }
44 45
45 void HeadlessBrowserImpl::Shutdown() { 46 void HeadlessBrowserImpl::Shutdown() {
(...skipping 30 matching lines...) Expand all
76 77
77 void HeadlessBrowserImpl::SetOptionsForTesting( 78 void HeadlessBrowserImpl::SetOptionsForTesting(
78 const HeadlessBrowser::Options& options) { 79 const HeadlessBrowser::Options& options) {
79 options_ = options; 80 options_ = options;
80 browser_context()->SetOptionsForTesting(options); 81 browser_context()->SetOptionsForTesting(options);
81 } 82 }
82 83
83 int HeadlessBrowserMain( 84 int HeadlessBrowserMain(
84 const HeadlessBrowser::Options& options, 85 const HeadlessBrowser::Options& options,
85 const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback) { 86 const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback) {
86 scoped_ptr<HeadlessBrowserImpl> browser( 87 std::unique_ptr<HeadlessBrowserImpl> browser(
87 new HeadlessBrowserImpl(on_browser_start_callback, options)); 88 new HeadlessBrowserImpl(on_browser_start_callback, options));
88 89
89 // TODO(skyostil): Implement custom message pumps. 90 // TODO(skyostil): Implement custom message pumps.
90 DCHECK(!options.message_pump); 91 DCHECK(!options.message_pump);
91 92
92 headless::HeadlessContentMainDelegate delegate(std::move(browser)); 93 headless::HeadlessContentMainDelegate delegate(std::move(browser));
93 content::ContentMainParams params(&delegate); 94 content::ContentMainParams params(&delegate);
94 params.argc = options.argc; 95 params.argc = options.argc;
95 params.argv = options.argv; 96 params.argv = options.argv;
96 return content::ContentMain(params); 97 return content::ContentMain(params);
97 } 98 }
98 99
99 } // namespace headless 100 } // namespace headless
OLDNEW
« no previous file with comments | « headless/lib/browser/headless_browser_impl.h ('k') | headless/lib/browser/headless_browser_main_parts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698