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

Side by Side Diff: dbus/test_service.cc

Issue 7800023: Linux: use MessageLoopProxy instead of base::Thread in our DBus client library. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
« no previous file with comments | « dbus/test_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "dbus/test_service.h" 5 #include "dbus/test_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/test/test_timeouts.h" 8 #include "base/test/test_timeouts.h"
9 #include "base/threading/platform_thread.h" 9 #include "base/threading/platform_thread.h"
10 #include "dbus/bus.h" 10 #include "dbus/bus.h"
11 #include "dbus/exported_object.h" 11 #include "dbus/exported_object.h"
12 #include "dbus/message.h" 12 #include "dbus/message.h"
13 13
14 namespace dbus { 14 namespace dbus {
15 15
16 // Echo, SlowEcho, BrokenMethod. 16 // Echo, SlowEcho, BrokenMethod.
17 const int TestService::kNumMethodsToExport = 3; 17 const int TestService::kNumMethodsToExport = 3;
18 18
19 TestService::Options::Options() 19 TestService::Options::Options() {
20 : dbus_thread(NULL) {
21 } 20 }
22 21
23 TestService::Options::~Options() { 22 TestService::Options::~Options() {
24 } 23 }
25 24
26 TestService::TestService(const Options& options) 25 TestService::TestService(const Options& options)
27 : base::Thread("TestService"), 26 : base::Thread("TestService"),
28 dbus_thread_(options.dbus_thread), 27 dbus_thread_message_loop_proxy_(options.dbus_thread_message_loop_proxy),
29 on_all_methods_exported_(false, false), 28 on_all_methods_exported_(false, false),
30 num_exported_methods_(0) { 29 num_exported_methods_(0) {
31 } 30 }
32 31
33 TestService::~TestService() { 32 TestService::~TestService() {
34 } 33 }
35 34
36 bool TestService::StartService() { 35 bool TestService::StartService() {
37 base::Thread::Options thread_options; 36 base::Thread::Options thread_options;
38 thread_options.message_loop_type = MessageLoop::TYPE_IO; 37 thread_options.message_loop_type = MessageLoop::TYPE_IO;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 92
94 ++num_exported_methods_; 93 ++num_exported_methods_;
95 if (num_exported_methods_ == kNumMethodsToExport) 94 if (num_exported_methods_ == kNumMethodsToExport)
96 on_all_methods_exported_.Signal(); 95 on_all_methods_exported_.Signal();
97 } 96 }
98 97
99 void TestService::Run(MessageLoop* message_loop) { 98 void TestService::Run(MessageLoop* message_loop) {
100 Bus::Options bus_options; 99 Bus::Options bus_options;
101 bus_options.bus_type = Bus::SESSION; 100 bus_options.bus_type = Bus::SESSION;
102 bus_options.connection_type = Bus::PRIVATE; 101 bus_options.connection_type = Bus::PRIVATE;
103 bus_options.dbus_thread = dbus_thread_; 102 bus_options.dbus_thread_message_loop_proxy = dbus_thread_message_loop_proxy_;
104 bus_ = new Bus(bus_options); 103 bus_ = new Bus(bus_options);
105 104
106 exported_object_ = bus_->GetExportedObject( 105 exported_object_ = bus_->GetExportedObject(
107 "org.chromium.TestService", 106 "org.chromium.TestService",
108 "/org/chromium/TestObject"); 107 "/org/chromium/TestObject");
109 108
110 int num_methods = 0; 109 int num_methods = 0;
111 exported_object_->ExportMethod( 110 exported_object_->ExportMethod(
112 "org.chromium.TestInterface", 111 "org.chromium.TestInterface",
113 "Echo", 112 "Echo",
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 Response* TestService::SlowEcho(MethodCall* method_call) { 157 Response* TestService::SlowEcho(MethodCall* method_call) {
159 base::PlatformThread::Sleep(TestTimeouts::tiny_timeout_ms()); 158 base::PlatformThread::Sleep(TestTimeouts::tiny_timeout_ms());
160 return Echo(method_call); 159 return Echo(method_call);
161 } 160 }
162 161
163 Response* TestService::BrokenMethod(MethodCall* method_call) { 162 Response* TestService::BrokenMethod(MethodCall* method_call) {
164 return NULL; 163 return NULL;
165 } 164 }
166 165
167 } // namespace dbus 166 } // namespace dbus
OLDNEW
« no previous file with comments | « dbus/test_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698