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

Side by Side Diff: chromecast/browser/media/cast_mojo_media_application.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/media/cast_mojo_media_application.h" 5 #include "chromecast/browser/media/cast_mojo_media_application.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "chromecast/browser/media/cast_mojo_media_client.h" 9 #include "chromecast/browser/media/cast_mojo_media_client.h"
10 #include "media/base/media_log.h" 10 #include "media/base/media_log.h"
11 #include "media/mojo/services/service_factory_impl.h" 11 #include "media/mojo/services/service_factory_impl.h"
12 #include "mojo/shell/public/cpp/connection.h" 12 #include "mojo/shell/public/cpp/connection.h"
13 13
14 namespace { 14 namespace {
15 void CreateServiceFactory( 15 void CreateServiceFactory(
16 mojo::InterfaceRequest<media::interfaces::ServiceFactory> request, 16 mojo::InterfaceRequest<media::interfaces::ServiceFactory> request,
17 mojo::shell::mojom::InterfaceProvider* interfaces, 17 mojo::shell::mojom::InterfaceProvider* interfaces,
18 scoped_refptr<media::MediaLog> media_log, 18 scoped_refptr<media::MediaLog> media_log,
19 scoped_ptr<mojo::MessageLoopRef> app_refcount, 19 std::unique_ptr<mojo::MessageLoopRef> app_refcount,
20 media::MojoMediaClient* mojo_media_client) { 20 media::MojoMediaClient* mojo_media_client) {
21 new ::media::ServiceFactoryImpl(std::move(request), interfaces, 21 new ::media::ServiceFactoryImpl(std::move(request), interfaces,
22 std::move(media_log), std::move(app_refcount), 22 std::move(media_log), std::move(app_refcount),
23 mojo_media_client); 23 mojo_media_client);
24 } 24 }
25 } // namespace 25 } // namespace
26 26
27 namespace chromecast { 27 namespace chromecast {
28 namespace media { 28 namespace media {
29 29
30 CastMojoMediaApplication::CastMojoMediaApplication( 30 CastMojoMediaApplication::CastMojoMediaApplication(
31 scoped_ptr<CastMojoMediaClient> mojo_media_client, 31 std::unique_ptr<CastMojoMediaClient> mojo_media_client,
32 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner) 32 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner)
33 : mojo_media_client_(std::move(mojo_media_client)), 33 : mojo_media_client_(std::move(mojo_media_client)),
34 media_task_runner_(media_task_runner), 34 media_task_runner_(media_task_runner),
35 media_log_(new ::media::MediaLog()) { 35 media_log_(new ::media::MediaLog()) {
36 DCHECK(mojo_media_client_); 36 DCHECK(mojo_media_client_);
37 DCHECK(media_task_runner_); 37 DCHECK(media_task_runner_);
38 } 38 }
39 39
40 CastMojoMediaApplication::~CastMojoMediaApplication() {} 40 CastMojoMediaApplication::~CastMojoMediaApplication() {}
41 41
42 void CastMojoMediaApplication::Initialize(mojo::Connector* connector, 42 void CastMojoMediaApplication::Initialize(mojo::Connector* connector,
43 const mojo::Identity& identity, 43 const mojo::Identity& identity,
44 uint32_t /* id */) {} 44 uint32_t /* id */) {}
45 45
46 bool CastMojoMediaApplication::AcceptConnection(mojo::Connection* connection) { 46 bool CastMojoMediaApplication::AcceptConnection(mojo::Connection* connection) {
47 connection->AddInterface<::media::interfaces::ServiceFactory>(this); 47 connection->AddInterface<::media::interfaces::ServiceFactory>(this);
48 return true; 48 return true;
49 } 49 }
50 50
51 void CastMojoMediaApplication::Create( 51 void CastMojoMediaApplication::Create(
52 mojo::Connection* connection, 52 mojo::Connection* connection,
53 mojo::InterfaceRequest<::media::interfaces::ServiceFactory> request) { 53 mojo::InterfaceRequest<::media::interfaces::ServiceFactory> request) {
54 // Create the app refcount here on the application task runner so that 54 // Create the app refcount here on the application task runner so that
55 // 1. It is bound to the application task runner, which in turn will 55 // 1. It is bound to the application task runner, which in turn will
56 // stop the app message loop when destroyed on the app task runner. 56 // stop the app message loop when destroyed on the app task runner.
57 // 2. It will prevent CastMojoMediaApplication from getting destroyed until 57 // 2. It will prevent CastMojoMediaApplication from getting destroyed until
58 // the task posted to the media thread is run. 58 // the task posted to the media thread is run.
59 scoped_ptr<mojo::MessageLoopRef> app_refcount = ref_factory_.CreateRef(); 59 std::unique_ptr<mojo::MessageLoopRef> app_refcount = ref_factory_.CreateRef();
60 media_task_runner_->PostTask( 60 media_task_runner_->PostTask(
61 FROM_HERE, 61 FROM_HERE,
62 base::Bind(&CreateServiceFactory, base::Passed(&request), 62 base::Bind(&CreateServiceFactory, base::Passed(&request),
63 connection->GetRemoteInterfaces(), media_log_, 63 connection->GetRemoteInterfaces(), media_log_,
64 base::Passed(&app_refcount), mojo_media_client_.get())); 64 base::Passed(&app_refcount), mojo_media_client_.get()));
65 } 65 }
66 66
67 } // namespace media 67 } // namespace media
68 } // namespace chromecast 68 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/browser/media/cast_mojo_media_application.h ('k') | chromecast/browser/media/cast_mojo_media_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698