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

Side by Side Diff: chromecast/browser/cast_content_browser_client.cc

Issue 1875623002: Convert //chromecast from scoped_ptr 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chromecast/browser/cast_content_browser_client.h" 5 #include "chromecast/browser/cast_content_browser_client.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8
8 #include <string> 9 #include <string>
9 #include <utility> 10 #include <utility>
10 11
11 #include "base/base_switches.h" 12 #include "base/base_switches.h"
12 #include "base/command_line.h" 13 #include "base/command_line.h"
13 #include "base/files/scoped_file.h" 14 #include "base/files/scoped_file.h"
14 #include "base/i18n/rtl.h" 15 #include "base/i18n/rtl.h"
15 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ptr_util.h"
16 #include "base/path_service.h" 18 #include "base/path_service.h"
17 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
18 #include "build/build_config.h" 20 #include "build/build_config.h"
19 #include "chromecast/base/cast_constants.h" 21 #include "chromecast/base/cast_constants.h"
20 #include "chromecast/base/cast_paths.h" 22 #include "chromecast/base/cast_paths.h"
21 #include "chromecast/base/chromecast_switches.h" 23 #include "chromecast/base/chromecast_switches.h"
22 #include "chromecast/browser/cast_browser_context.h" 24 #include "chromecast/browser/cast_browser_context.h"
23 #include "chromecast/browser/cast_browser_main_parts.h" 25 #include "chromecast/browser/cast_browser_main_parts.h"
24 #include "chromecast/browser/cast_browser_process.h" 26 #include "chromecast/browser/cast_browser_process.h"
25 #include "chromecast/browser/cast_network_delegate.h" 27 #include "chromecast/browser/cast_network_delegate.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 #include "components/external_video_surface/browser/android/external_video_surfa ce_container_impl.h" 61 #include "components/external_video_surface/browser/android/external_video_surfa ce_container_impl.h"
60 #else 62 #else
61 #include "chromecast/browser/media/cast_browser_cdm_factory.h" 63 #include "chromecast/browser/media/cast_browser_cdm_factory.h"
62 #endif // defined(OS_ANDROID) 64 #endif // defined(OS_ANDROID)
63 65
64 namespace chromecast { 66 namespace chromecast {
65 namespace shell { 67 namespace shell {
66 68
67 namespace { 69 namespace {
68 #if defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS) 70 #if defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS)
69 static scoped_ptr<mojo::ShellClient> CreateCastMojoMediaApplication( 71 static std::unique_ptr<mojo::ShellClient> CreateCastMojoMediaApplication(
70 CastContentBrowserClient* browser_client) { 72 CastContentBrowserClient* browser_client) {
71 scoped_ptr<media::CastMojoMediaClient> mojo_media_client( 73 std::unique_ptr<media::CastMojoMediaClient> mojo_media_client(
72 new media::CastMojoMediaClient( 74 new media::CastMojoMediaClient(
73 base::Bind(&CastContentBrowserClient::CreateMediaPipelineBackend, 75 base::Bind(&CastContentBrowserClient::CreateMediaPipelineBackend,
74 base::Unretained(browser_client)))); 76 base::Unretained(browser_client))));
75 return scoped_ptr<mojo::ShellClient>(new media::CastMojoMediaApplication( 77 return std::unique_ptr<mojo::ShellClient>(new media::CastMojoMediaApplication(
76 std::move(mojo_media_client), browser_client->GetMediaTaskRunner())); 78 std::move(mojo_media_client), browser_client->GetMediaTaskRunner()));
77 } 79 }
78 #endif // ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS 80 #endif // ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS
79 } // namespace 81 } // namespace
80 82
81 CastContentBrowserClient::CastContentBrowserClient() 83 CastContentBrowserClient::CastContentBrowserClient()
82 : cast_browser_main_parts_(nullptr), 84 : cast_browser_main_parts_(nullptr),
83 url_request_context_factory_(new URLRequestContextFactory()) {} 85 url_request_context_factory_(new URLRequestContextFactory()) {}
84 86
85 CastContentBrowserClient::~CastContentBrowserClient() { 87 CastContentBrowserClient::~CastContentBrowserClient() {
86 content::BrowserThread::DeleteSoon( 88 content::BrowserThread::DeleteSoon(
87 content::BrowserThread::IO, 89 content::BrowserThread::IO,
88 FROM_HERE, 90 FROM_HERE,
89 url_request_context_factory_.release()); 91 url_request_context_factory_.release());
90 } 92 }
91 93
92 void CastContentBrowserClient::AppendExtraCommandLineSwitches( 94 void CastContentBrowserClient::AppendExtraCommandLineSwitches(
93 base::CommandLine* command_line) { 95 base::CommandLine* command_line) {
94 } 96 }
95 97
96 void CastContentBrowserClient::PreCreateThreads() { 98 void CastContentBrowserClient::PreCreateThreads() {
97 } 99 }
98 100
99 scoped_ptr<CastService> CastContentBrowserClient::CreateCastService( 101 std::unique_ptr<CastService> CastContentBrowserClient::CreateCastService(
100 content::BrowserContext* browser_context, 102 content::BrowserContext* browser_context,
101 PrefService* pref_service, 103 PrefService* pref_service,
102 net::URLRequestContextGetter* request_context_getter, 104 net::URLRequestContextGetter* request_context_getter,
103 media::VideoPlaneController* video_plane_controller) { 105 media::VideoPlaneController* video_plane_controller) {
104 return make_scoped_ptr(new CastServiceSimple(browser_context, pref_service)); 106 return base::WrapUnique(new CastServiceSimple(browser_context, pref_service));
105 } 107 }
106 108
107 #if !defined(OS_ANDROID) 109 #if !defined(OS_ANDROID)
108 scoped_refptr<base::SingleThreadTaskRunner> 110 scoped_refptr<base::SingleThreadTaskRunner>
109 CastContentBrowserClient::GetMediaTaskRunner() { 111 CastContentBrowserClient::GetMediaTaskRunner() {
110 DCHECK(cast_browser_main_parts_); 112 DCHECK(cast_browser_main_parts_);
111 return cast_browser_main_parts_->GetMediaTaskRunner(); 113 return cast_browser_main_parts_->GetMediaTaskRunner();
112 } 114 }
113 115
114 scoped_ptr<media::MediaPipelineBackend> 116 std::unique_ptr<media::MediaPipelineBackend>
115 CastContentBrowserClient::CreateMediaPipelineBackend( 117 CastContentBrowserClient::CreateMediaPipelineBackend(
116 const media::MediaPipelineDeviceParams& params) { 118 const media::MediaPipelineDeviceParams& params) {
117 return media_pipeline_backend_manager()->CreateMediaPipelineBackend(params); 119 return media_pipeline_backend_manager()->CreateMediaPipelineBackend(params);
118 } 120 }
119 121
120 media::MediaResourceTracker* 122 media::MediaResourceTracker*
121 CastContentBrowserClient::media_resource_tracker() { 123 CastContentBrowserClient::media_resource_tracker() {
122 return cast_browser_main_parts_->media_resource_tracker(); 124 return cast_browser_main_parts_->media_resource_tracker();
123 } 125 }
124 126
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 // to retrieve media data chunks while running in a https page. This pref 269 // to retrieve media data chunks while running in a https page. This pref
268 // should be disabled once all the content providers are no longer doing that. 270 // should be disabled once all the content providers are no longer doing that.
269 prefs->allow_running_insecure_content = true; 271 prefs->allow_running_insecure_content = true;
270 272
271 // Enable 5% margins for WebVTT cues to keep within title-safe area 273 // Enable 5% margins for WebVTT cues to keep within title-safe area
272 prefs->text_track_margin_percentage = 5; 274 prefs->text_track_margin_percentage = 5;
273 } 275 }
274 276
275 void CastContentBrowserClient::ResourceDispatcherHostCreated() { 277 void CastContentBrowserClient::ResourceDispatcherHostCreated() {
276 CastBrowserProcess::GetInstance()->SetResourceDispatcherHostDelegate( 278 CastBrowserProcess::GetInstance()->SetResourceDispatcherHostDelegate(
277 make_scoped_ptr(new CastResourceDispatcherHostDelegate)); 279 base::WrapUnique(new CastResourceDispatcherHostDelegate));
278 content::ResourceDispatcherHost::Get()->SetDelegate( 280 content::ResourceDispatcherHost::Get()->SetDelegate(
279 CastBrowserProcess::GetInstance()->resource_dispatcher_host_delegate()); 281 CastBrowserProcess::GetInstance()->resource_dispatcher_host_delegate());
280 } 282 }
281 283
282 std::string CastContentBrowserClient::GetApplicationLocale() { 284 std::string CastContentBrowserClient::GetApplicationLocale() {
283 const std::string locale(base::i18n::GetConfiguredLocale()); 285 const std::string locale(base::i18n::GetConfiguredLocale());
284 return locale.empty() ? "en-US" : locale; 286 return locale.empty() ? "en-US" : locale;
285 } 287 }
286 288
287 content::QuotaPermissionContext* 289 content::QuotaPermissionContext*
(...skipping 14 matching lines...) Expand all
302 content::CertificateRequestResultType* result) { 304 content::CertificateRequestResultType* result) {
303 // Allow developers to override certificate errors. 305 // Allow developers to override certificate errors.
304 // Otherwise, any fatal certificate errors will cause an abort. 306 // Otherwise, any fatal certificate errors will cause an abort.
305 *result = content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL; 307 *result = content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL;
306 return; 308 return;
307 } 309 }
308 310
309 void CastContentBrowserClient::SelectClientCertificate( 311 void CastContentBrowserClient::SelectClientCertificate(
310 content::WebContents* web_contents, 312 content::WebContents* web_contents,
311 net::SSLCertRequestInfo* cert_request_info, 313 net::SSLCertRequestInfo* cert_request_info,
312 scoped_ptr<content::ClientCertificateDelegate> delegate) { 314 std::unique_ptr<content::ClientCertificateDelegate> delegate) {
313 GURL requesting_url("https://" + cert_request_info->host_and_port.ToString()); 315 GURL requesting_url("https://" + cert_request_info->host_and_port.ToString());
314 316
315 if (!requesting_url.is_valid()) { 317 if (!requesting_url.is_valid()) {
316 LOG(ERROR) << "Invalid URL string: " 318 LOG(ERROR) << "Invalid URL string: "
317 << requesting_url.possibly_invalid_spec(); 319 << requesting_url.possibly_invalid_spec();
318 delegate->ContinueWithCertificate(nullptr); 320 delegate->ContinueWithCertificate(nullptr);
319 return; 321 return;
320 } 322 }
321 323
322 // In our case there are no relevant certs in the cert_request_info. The cert 324 // In our case there are no relevant certs in the cert_request_info. The cert
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 << "be disabled for this process."; 411 << "be disabled for this process.";
410 } else { 412 } else {
411 mappings->Transfer(kAndroidMinidumpDescriptor, 413 mappings->Transfer(kAndroidMinidumpDescriptor,
412 base::ScopedFD(minidump_file.TakePlatformFile())); 414 base::ScopedFD(minidump_file.TakePlatformFile()));
413 } 415 }
414 } 416 }
415 } 417 }
416 418
417 #else 419 #else
418 420
419 scoped_ptr<::media::CdmFactory> CastContentBrowserClient::CreateCdmFactory() { 421 std::unique_ptr<::media::CdmFactory>
422 CastContentBrowserClient::CreateCdmFactory() {
420 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 423 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
421 switches::kEnableCmaMediaPipeline)) { 424 switches::kEnableCmaMediaPipeline)) {
422 return make_scoped_ptr(new media::CastBrowserCdmFactory( 425 return base::WrapUnique(new media::CastBrowserCdmFactory(
423 GetMediaTaskRunner(), media_resource_tracker())); 426 GetMediaTaskRunner(), media_resource_tracker()));
424 } 427 }
425 428
426 return nullptr; 429 return nullptr;
427 } 430 }
428 431
429 void CastContentBrowserClient::GetAdditionalMappedFilesForChildProcess( 432 void CastContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
430 const base::CommandLine& command_line, 433 const base::CommandLine& command_line,
431 int child_process_id, 434 int child_process_id,
432 content::FileDescriptorInfo* mappings) { 435 content::FileDescriptorInfo* mappings) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 process_type, dumps_path, false /* upload */); 490 process_type, dumps_path, false /* upload */);
488 // StartUploaderThread() even though upload is diferred. 491 // StartUploaderThread() even though upload is diferred.
489 // Breakpad-related memory is freed in the uploader thread. 492 // Breakpad-related memory is freed in the uploader thread.
490 crash_handler->StartUploaderThread(); 493 crash_handler->StartUploaderThread();
491 return crash_handler; 494 return crash_handler;
492 } 495 }
493 #endif // !defined(OS_ANDROID) 496 #endif // !defined(OS_ANDROID)
494 497
495 } // namespace shell 498 } // namespace shell
496 } // namespace chromecast 499 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/browser/cast_content_browser_client.h ('k') | chromecast/browser/cast_content_browser_client_simple.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698