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

Side by Side Diff: chrome/browser/chromeos/arc/gpu_arc_video_service_host.cc

Issue 2326913003: Privatize StrongBinding lifetime management (Closed)
Patch Set: rebase Created 4 years, 3 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 "chrome/browser/chromeos/arc/gpu_arc_video_service_host.h" 5 #include "chrome/browser/chromeos/arc/gpu_arc_video_service_host.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 24 matching lines...) Expand all
35 35
36 void ConnectToVideoAcceleratorServiceOnIOThread( 36 void ConnectToVideoAcceleratorServiceOnIOThread(
37 mojom::VideoAcceleratorServiceRequest request) { 37 mojom::VideoAcceleratorServiceRequest request) {
38 content::GetGpuRemoteInterfaces()->GetInterface(std::move(request)); 38 content::GetGpuRemoteInterfaces()->GetInterface(std::move(request));
39 } 39 }
40 40
41 } // namespace 41 } // namespace
42 42
43 class VideoAcceleratorFactoryService : public mojom::VideoAcceleratorFactory { 43 class VideoAcceleratorFactoryService : public mojom::VideoAcceleratorFactory {
44 public: 44 public:
45 explicit VideoAcceleratorFactoryService( 45 VideoAcceleratorFactoryService() = default;
46 mojom::VideoAcceleratorFactoryRequest request)
47 : binding_(this, std::move(request)) {}
48 46
49 void Create(mojom::VideoAcceleratorServiceRequest request) override { 47 void Create(mojom::VideoAcceleratorServiceRequest request) override {
50 content::BrowserThread::PostTask( 48 content::BrowserThread::PostTask(
51 content::BrowserThread::IO, FROM_HERE, 49 content::BrowserThread::IO, FROM_HERE,
52 base::Bind(&ConnectToVideoAcceleratorServiceOnIOThread, 50 base::Bind(&ConnectToVideoAcceleratorServiceOnIOThread,
53 base::Passed(&request))); 51 base::Passed(&request)));
54 } 52 }
55 53
56 private: 54 private:
57 mojo::StrongBinding<VideoAcceleratorFactory> binding_;
58
59 DISALLOW_COPY_AND_ASSIGN(VideoAcceleratorFactoryService); 55 DISALLOW_COPY_AND_ASSIGN(VideoAcceleratorFactoryService);
60 }; 56 };
61 57
62 GpuArcVideoServiceHost::GpuArcVideoServiceHost( 58 GpuArcVideoServiceHost::GpuArcVideoServiceHost(
63 arc::ArcBridgeService* bridge_service) 59 arc::ArcBridgeService* bridge_service)
64 : ArcService(bridge_service), binding_(this) { 60 : ArcService(bridge_service), binding_(this) {
65 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 61 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
66 arc_bridge_service()->video()->AddObserver(this); 62 arc_bridge_service()->video()->AddObserver(this);
67 } 63 }
68 64
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 std::string token = mojo::edk::GenerateRandomToken(); 139 std::string token = mojo::edk::GenerateRandomToken();
144 mojo::ScopedMessagePipeHandle server_pipe = 140 mojo::ScopedMessagePipeHandle server_pipe =
145 mojo::edk::CreateParentMessagePipe(token, child_token); 141 mojo::edk::CreateParentMessagePipe(token, child_token);
146 if (!server_pipe.is_valid()) { 142 if (!server_pipe.is_valid()) {
147 LOG(ERROR) << "Invalid pipe"; 143 LOG(ERROR) << "Invalid pipe";
148 callback.Run(mojo::ScopedHandle(), std::string()); 144 callback.Run(mojo::ScopedHandle(), std::string());
149 return; 145 return;
150 } 146 }
151 callback.Run(std::move(child_handle), token); 147 callback.Run(std::move(child_handle), token);
152 148
153 // The lifetime is managed by the StrongBinding insides the 149 mojo::MakeStrongBinding(base::MakeUnique<VideoAcceleratorFactoryService>(),
154 // VideoAcceleratorFactoryService. 150 mojo::MakeRequest<mojom::VideoAcceleratorFactory>(
155 new VideoAcceleratorFactoryService( 151 std::move(server_pipe)));
156 mojo::MakeRequest<mojom::VideoAcceleratorFactory>(
157 std::move(server_pipe)));
158 } 152 }
159 153
160 } // namespace arc 154 } // namespace arc
OLDNEW
« no previous file with comments | « chrome/browser/budget_service/budget_service_impl.cc ('k') | chrome/browser/chromeos/attestation/platform_verification_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698