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

Side by Side Diff: mojo/shell/profile_service_loader.cc

Issue 380413003: Mojo: Use InterfaceFactory<Interface> for service registration (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: some InterfaceProvider impls for common cases Created 6 years, 5 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 | Annotate | Revision Log
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 "mojo/shell/profile_service_loader.h" 5 #include "mojo/shell/profile_service_loader.h"
6 6
7 #include "mojo/public/cpp/application/application_connection.h" 7 #include "mojo/public/cpp/application/application_connection.h"
8 #include "mojo/public/cpp/application/application_delegate.h" 8 #include "mojo/public/cpp/application/application_delegate.h"
9 #include "mojo/public/cpp/application/application_impl.h" 9 #include "mojo/public/cpp/application/application_impl.h"
10 #include "mojo/services/profile/profile_service_impl.h"
11 10
12 namespace mojo { 11 namespace mojo {
13 namespace shell { 12 namespace shell {
14 13
15 ProfileServiceLoader::ProfileServiceLoader() { 14 ProfileServiceLoader::ProfileServiceLoader() {
16 } 15 }
17 16
18 ProfileServiceLoader::~ProfileServiceLoader() { 17 ProfileServiceLoader::~ProfileServiceLoader() {
19 } 18 }
20 19
21 void ProfileServiceLoader::LoadService( 20 void ProfileServiceLoader::LoadService(
22 ServiceManager* manager, 21 ServiceManager* manager,
23 const GURL& url, 22 const GURL& url,
24 ScopedMessagePipeHandle shell_handle) { 23 ScopedMessagePipeHandle shell_handle) {
25 uintptr_t key = reinterpret_cast<uintptr_t>(manager); 24 uintptr_t key = reinterpret_cast<uintptr_t>(manager);
26 if (apps_.find(key) == apps_.end()) { 25 if (apps_.find(key) == apps_.end()) {
27 scoped_ptr<ApplicationImpl> app( 26 scoped_ptr<ApplicationImpl> app(
28 new ApplicationImpl(this, shell_handle.Pass())); 27 new ApplicationImpl(this, shell_handle.Pass()));
29 apps_.add(key, app.Pass()); 28 apps_.add(key, app.Pass());
30 } 29 }
31 } 30 }
32 31
33 void ProfileServiceLoader::OnServiceError(ServiceManager* manager, 32 void ProfileServiceLoader::OnServiceError(ServiceManager* manager,
34 const GURL& url) { 33 const GURL& url) {
35 apps_.erase(reinterpret_cast<uintptr_t>(manager)); 34 apps_.erase(reinterpret_cast<uintptr_t>(manager));
36 } 35 }
37 36
38 bool ProfileServiceLoader::ConfigureIncomingConnection( 37 bool ProfileServiceLoader::ConfigureIncomingConnection(
39 ApplicationConnection* connection) { 38 ApplicationConnection* connection) {
40 connection->AddService<ProfileServiceImpl>(); 39 connection->AddServiceProvider(this);
41 return true; 40 return true;
42 } 41 }
43 42
43 void ProfileServiceLoader::BindToRequest(
44 ApplicationConnection* connection,
45 InterfaceRequest<ProfileService> request) {
46 // We can bind all requests to the same ProfileServiceImpl since there is no
47 // client for ProfileService.
48 mojo::BindToRequest(&impl_, &request);
49 }
50
44 } // namespace shell 51 } // namespace shell
45 } // namespace mojo 52 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698