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: mojo/shell/dbus_service_loader_linux.cc

Issue 294833002: Mojo: more idiomatic C++ bindings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more 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"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/task_runner_util.h" 12 #include "base/task_runner_util.h"
13 #include "base/threading/thread_restrictions.h" 13 #include "base/threading/thread_restrictions.h"
14 #include "dbus/bus.h" 14 #include "dbus/bus.h"
15 #include "dbus/file_descriptor.h" 15 #include "dbus/file_descriptor.h"
16 #include "dbus/message.h" 16 #include "dbus/message.h"
17 #include "dbus/object_path.h" 17 #include "dbus/object_path.h"
18 #include "dbus/object_proxy.h" 18 #include "dbus/object_proxy.h"
19 #include "mojo/common/channel_init.h" 19 #include "mojo/common/channel_init.h"
20 #include "mojo/dbus/dbus_external_service.h" 20 #include "mojo/dbus/dbus_external_service.h"
21 #include "mojo/embedder/platform_channel_pair.h" 21 #include "mojo/embedder/platform_channel_pair.h"
22 #include "mojo/public/cpp/bindings/allocation_scope.h"
23 #include "mojo/shell/context.h" 22 #include "mojo/shell/context.h"
24 #include "mojo/shell/external_service.mojom.h" 23 #include "mojo/shell/external_service.mojom.h"
25 #include "mojo/shell/keep_alive.h" 24 #include "mojo/shell/keep_alive.h"
26 25
27 namespace mojo { 26 namespace mojo {
28 namespace shell { 27 namespace shell {
29 28
30 // Manages the connection to a single externally-running service. 29 // Manages the connection to a single externally-running service.
31 class DBusServiceLoader::LoadContext { 30 class DBusServiceLoader::LoadContext {
32 public: 31 public:
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 // TODO(cmasone): handle errors! 97 // TODO(cmasone): handle errors!
99 service_dbus_proxy_->CallMethod( 98 service_dbus_proxy_->CallMethod(
100 &call, 99 &call,
101 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 100 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
102 base::Bind(&LoadContext::ActivateService, base::Unretained(this))); 101 base::Bind(&LoadContext::ActivateService, base::Unretained(this)));
103 } 102 }
104 103
105 // Sends a ShellHandle over to the now-connected externally-running service, 104 // Sends a ShellHandle over to the now-connected externally-running service,
106 // using the Mojo ExternalService API. 105 // using the Mojo ExternalService API.
107 void ActivateService(dbus::Response* response) { 106 void ActivateService(dbus::Response* response) {
108 mojo::AllocationScope scope;
109 external_service_->Activate( 107 external_service_->Activate(
110 mojo::ScopedMessagePipeHandle( 108 mojo::ScopedMessagePipeHandle(
111 mojo::MessagePipeHandle(shell_handle_.release().value()))); 109 mojo::MessagePipeHandle(shell_handle_.release().value())));
112 } 110 }
113 111
114 // Should the ExternalService disappear completely, destroy connection state. 112 // Should the ExternalService disappear completely, destroy connection state.
115 // NB: This triggers off of the service disappearing from 113 // NB: This triggers off of the service disappearing from
116 // DBus. Perhaps there's a way to watch at the Mojo layer instead, 114 // DBus. Perhaps there's a way to watch at the Mojo layer instead,
117 // and that would be superior? 115 // and that would be superior?
118 void HandleNameOwnerChanged(const std::string& old_owner, 116 void HandleNameOwnerChanged(const std::string& old_owner,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 DCHECK(it != url_to_load_context_.end()) << url; 171 DCHECK(it != url_to_load_context_.end()) << url;
174 172
175 LoadContext* doomed = it->second; 173 LoadContext* doomed = it->second;
176 url_to_load_context_.erase(it); 174 url_to_load_context_.erase(it);
177 175
178 delete doomed; 176 delete doomed;
179 } 177 }
180 178
181 } // namespace shell 179 } // namespace shell
182 } // namespace mojo 180 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698