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

Side by Side Diff: components/core_services/core_services_application_delegate.cc

Issue 1115363002: mojo: Use ContentHandlers to bundle multiple Applications into a module. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 "components/core_services/core_services_application_delegate.h" 5 #include "components/core_services/core_services_application_delegate.h"
6 6
7 #include "components/clipboard/clipboard_standalone_impl.h" 7 #include "components/clipboard/clipboard_application_delegate.h"
8 #include "third_party/mojo/src/mojo/public/cpp/application/application_connectio n.h" 8 #include "third_party/mojo/src/mojo/public/cpp/application/application_connectio n.h"
9 #include "third_party/mojo/src/mojo/public/cpp/application/application_impl.h"
9 10
10 namespace core_services { 11 namespace core_services {
11 12
12 CoreServicesApplicationDelegate::CoreServicesApplicationDelegate() {} 13 CoreServicesApplicationDelegate::CoreServicesApplicationDelegate() {}
13 14
14 CoreServicesApplicationDelegate::~CoreServicesApplicationDelegate() {} 15 CoreServicesApplicationDelegate::~CoreServicesApplicationDelegate() {}
15 16
16 bool CoreServicesApplicationDelegate::ConfigureIncomingConnection( 17 bool CoreServicesApplicationDelegate::ConfigureIncomingConnection(
17 mojo::ApplicationConnection* connection) { 18 mojo::ApplicationConnection* connection) {
18 // TODO(erg): For version one, we'll just say that all incoming connections 19 connection->AddService(this);
19 // get access to the same objects, which imply that there will be one
20 // instance of the service in its own process. However, in the long run,
21 // we'll want this to be more configurable. Some services are singletons,
22 // while we'll want to spawn a new process with multiple instances for other
23 // services.
24 connection->AddService<mojo::ServiceProvider>(this);
25 return true; 20 return true;
26 } 21 }
27 22
28 void CoreServicesApplicationDelegate::Create( 23 void CoreServicesApplicationDelegate::Create(
29 mojo::ApplicationConnection* connection, 24 mojo::ApplicationConnection* connection,
30 mojo::InterfaceRequest<ServiceProvider> request) { 25 mojo::InterfaceRequest<mojo::ContentHandler> request) {
31 provider_bindings_.AddBinding(this, request.Pass()); 26 handler_bindings_.AddBinding(this, request.Pass());
32 } 27 }
33 28
34 void CoreServicesApplicationDelegate::ConnectToService( 29 void CoreServicesApplicationDelegate::StartApplication(
35 const mojo::String& service_name, 30 mojo::InterfaceRequest<mojo::Application> request,
36 mojo::ScopedMessagePipeHandle client_handle) { 31 mojo::URLResponsePtr response) {
37 if (service_name == mojo::Clipboard::Name_) { 32 std::string url = response->url;
38 // TODO(erg): So what we do here probably doesn't look like the 33 if (url == "mojo://clipboard/") {
39 // InProcessNativeRunner / NativeApplicationSupport. 34 // TODO(erg): This is where we should deal with running things on separate
40 // native_application_support.cc does the whole SetThunks() stuff. This has 35 // threads.
41 // already happened since Core Services is a mojo application. So we want 36 new mojo::ApplicationImpl(new clipboard::ClipboardApplicationDelegate,
sky 2015/04/30 21:59:08 I suspect this leaks. Can you add a TODO about tra
Elliot Glaysher 2015/05/01 17:00:03 Switched to smart ptrs.
42 // some sort of lightweight runner here. 37 request.Pass());
43 // 38 return;
44 // But...the actual child process stuff is its own mojom! (Also, it's 39 }
45 // entangled with mojo::Shell::ChildProcessMain().) All concept of app
46 // paths are the things which are used to execute the application in
47 // child_process.cc.
48 40
49 // TODO(erg): The lifetime of ClipboardStandaloneImpl is wrong. Right now, 41 NOTREACHED() << "Unknown service '" << url << "'";
50 // a new object is made for each request, but we obviously want there to be
51 // one clipboard across all callers.
52 new clipboard::ClipboardStandaloneImpl(
53 mojo::MakeRequest<mojo::Clipboard>(client_handle.Pass()));
54 }
55 } 42 }
56 43
57 } // namespace core_services 44 } // namespace core_services
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698