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

Side by Side Diff: trunk/src/mojo/shell/dbus_service_loader_linux.cc

Issue 304593002: Revert 272983 "Change Shell / ShellClient to ServiceProvider" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 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 | 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/dbus_service_loader_linux.h" 5 #include "mojo/shell/dbus_service_loader_linux.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 19 matching lines...) Expand all
30 // Manages the connection to a single externally-running service. 30 // Manages the connection to a single externally-running service.
31 class DBusServiceLoader::LoadContext { 31 class DBusServiceLoader::LoadContext {
32 public: 32 public:
33 // Kicks off the attempt to bootstrap a connection to the externally-running 33 // Kicks off the attempt to bootstrap a connection to the externally-running
34 // service specified by url_. 34 // service specified by url_.
35 // Creates a MessagePipe and passes one end over DBus to the service. Then, 35 // Creates a MessagePipe and passes one end over DBus to the service. Then,
36 // calls ExternalService::Activate(ShellHandle) over the now-shared pipe. 36 // calls ExternalService::Activate(ShellHandle) over the now-shared pipe.
37 LoadContext(DBusServiceLoader* loader, 37 LoadContext(DBusServiceLoader* loader,
38 const scoped_refptr<dbus::Bus>& bus, 38 const scoped_refptr<dbus::Bus>& bus,
39 const GURL& url, 39 const GURL& url,
40 ScopedMessagePipeHandle service_provider_handle) 40 ScopedMessagePipeHandle shell_handle)
41 : loader_(loader), 41 : loader_(loader),
42 bus_(bus), 42 bus_(bus),
43 service_dbus_proxy_(NULL), 43 service_dbus_proxy_(NULL),
44 url_(url), 44 url_(url),
45 service_provider_handle_(service_provider_handle.Pass()), 45 shell_handle_(shell_handle.Pass()),
46 keep_alive_(loader->context_) { 46 keep_alive_(loader->context_) {
47 base::PostTaskAndReplyWithResult( 47 base::PostTaskAndReplyWithResult(
48 loader_->context_->task_runners()->io_runner(), 48 loader_->context_->task_runners()->io_runner(),
49 FROM_HERE, 49 FROM_HERE,
50 base::Bind(&LoadContext::CreateChannelOnIOThread, 50 base::Bind(&LoadContext::CreateChannelOnIOThread,
51 base::Unretained(this)), 51 base::Unretained(this)),
52 base::Bind(&LoadContext::ConnectChannel, base::Unretained(this))); 52 base::Bind(&LoadContext::ConnectChannel, base::Unretained(this)));
53 } 53 }
54 54
55 virtual ~LoadContext() { 55 virtual ~LoadContext() {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 101 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
102 base::Bind(&LoadContext::ActivateService, base::Unretained(this))); 102 base::Bind(&LoadContext::ActivateService, base::Unretained(this)));
103 } 103 }
104 104
105 // Sends a ShellHandle over to the now-connected externally-running service, 105 // Sends a ShellHandle over to the now-connected externally-running service,
106 // using the Mojo ExternalService API. 106 // using the Mojo ExternalService API.
107 void ActivateService(dbus::Response* response) { 107 void ActivateService(dbus::Response* response) {
108 mojo::AllocationScope scope; 108 mojo::AllocationScope scope;
109 external_service_->Activate( 109 external_service_->Activate(
110 mojo::ScopedMessagePipeHandle( 110 mojo::ScopedMessagePipeHandle(
111 mojo::MessagePipeHandle( 111 mojo::MessagePipeHandle(shell_handle_.release().value())));
112 service_provider_handle_.release().value())));
113 } 112 }
114 113
115 // Should the ExternalService disappear completely, destroy connection state. 114 // Should the ExternalService disappear completely, destroy connection state.
116 // NB: This triggers off of the service disappearing from 115 // NB: This triggers off of the service disappearing from
117 // DBus. Perhaps there's a way to watch at the Mojo layer instead, 116 // DBus. Perhaps there's a way to watch at the Mojo layer instead,
118 // and that would be superior? 117 // and that would be superior?
119 void HandleNameOwnerChanged(const std::string& old_owner, 118 void HandleNameOwnerChanged(const std::string& old_owner,
120 const std::string& new_owner) { 119 const std::string& new_owner) {
121 DCHECK(loader_->context_->task_runners()->ui_runner()-> 120 DCHECK(loader_->context_->task_runners()->ui_runner()->
122 BelongsToCurrentThread()); 121 BelongsToCurrentThread());
123 122
124 if (new_owner.empty()) { 123 if (new_owner.empty()) {
125 loader_->context_->task_runners()->ui_runner()->PostTask( 124 loader_->context_->task_runners()->ui_runner()->PostTask(
126 FROM_HERE, 125 FROM_HERE,
127 base::Bind(&DBusServiceLoader::ForgetService, 126 base::Bind(&DBusServiceLoader::ForgetService,
128 base::Unretained(loader_), url_)); 127 base::Unretained(loader_), url_));
129 } 128 }
130 } 129 }
131 130
132 DBusServiceLoader* const loader_; 131 DBusServiceLoader* const loader_;
133 scoped_refptr<dbus::Bus> bus_; 132 scoped_refptr<dbus::Bus> bus_;
134 dbus::ObjectProxy* service_dbus_proxy_; // Owned by bus_; 133 dbus::ObjectProxy* service_dbus_proxy_; // Owned by bus_;
135 const GURL url_; 134 const GURL url_;
136 ScopedMessagePipeHandle service_provider_handle_; 135 ScopedMessagePipeHandle shell_handle_;
137 KeepAlive keep_alive_; 136 KeepAlive keep_alive_;
138 scoped_ptr<common::ChannelInit> channel_init_; 137 scoped_ptr<common::ChannelInit> channel_init_;
139 ExternalServicePtr external_service_; 138 ExternalServicePtr external_service_;
140 139
141 DISALLOW_COPY_AND_ASSIGN(LoadContext); 140 DISALLOW_COPY_AND_ASSIGN(LoadContext);
142 }; 141 };
143 142
144 DBusServiceLoader::DBusServiceLoader(Context* context) : context_(context) { 143 DBusServiceLoader::DBusServiceLoader(Context* context) : context_(context) {
145 dbus::Bus::Options options; 144 dbus::Bus::Options options;
146 options.bus_type = dbus::Bus::SESSION; 145 options.bus_type = dbus::Bus::SESSION;
(...skipping 27 matching lines...) Expand all
174 DCHECK(it != url_to_load_context_.end()) << url; 173 DCHECK(it != url_to_load_context_.end()) << url;
175 174
176 LoadContext* doomed = it->second; 175 LoadContext* doomed = it->second;
177 url_to_load_context_.erase(it); 176 url_to_load_context_.erase(it);
178 177
179 delete doomed; 178 delete doomed;
180 } 179 }
181 180
182 } // namespace shell 181 } // namespace shell
183 } // namespace mojo 182 } // namespace mojo
OLDNEW
« no previous file with comments | « trunk/src/mojo/shell/dbus_service_loader_linux.h ('k') | trunk/src/mojo/shell/dynamic_service_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698