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

Unified Diff: dbus/test_service.h

Issue 7491029: Implement Bus and ObjectProxy classes for our D-Bus library. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: another clang challenge Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dbus/scoped_dbus_error.h ('k') | dbus/test_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dbus/test_service.h
diff --git a/dbus/test_service.h b/dbus/test_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..362ecb7cc6b02d3f56a2f7d0cca9f9961e226b59
--- /dev/null
+++ b/dbus/test_service.h
@@ -0,0 +1,73 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef DBUS_TEST_SERVICE_H_
+#define DBUS_TEST_SERVICE_H_
+#pragma once
+
+#include "base/memory/ref_counted.h"
+#include "base/threading/thread.h"
+#include "base/synchronization/condition_variable.h"
+#include "base/synchronization/lock.h"
+
+namespace dbus {
+
+class Bus;
+class ExportedObject;
+class MethodCall;
+class Response;
+
+// The test service is used for end-to-end tests. The service runs in a
+// separate thread, so it does not interfere the test code that runs in
+// the main thread. Methods such as Echo() and SlowEcho() are exported.
+class TestService : public base::Thread {
+ public:
+ // SlowEcho() sleeps for this period of time before returns.
+ static const int kSlowEchoSleepMs;
+
+ TestService();
+ virtual ~TestService();
+
+ // Starts the service in a separate thread.
+ void StartService();
+
+ // Waits until the service is started (i.e. methods are exported).
+ void WaitUntilServiceIsStarted();
+
+ private:
+ // Called when the service is started (i.e. the task is run from the
+ // message loop).
+ void OnServiceStarted();
+
+ // base::Thread override.
+ virtual void Run(MessageLoop* message_loop);
+
+ // base::Thread override.
+ virtual void CleanUp();
+
+ //
+ // Exported methods.
+ //
+
+ // Echos the text message received from the method call.
+ Response* Echo(MethodCall* method_call);
+
+ // Echos the text message received from the method call, but sleeps for
+ // kSlowEchoSleepMs before returning the response.
+ Response* SlowEcho(MethodCall* method_call);
+
+ // Returns NULL, instead of a valid Response.
+ Response* BrokenMethod(MethodCall* method_call);
+
+ bool service_started_;
+ base::Lock service_started_lock_;
+ base::ConditionVariable on_service_started_;
+
+ scoped_refptr<Bus> bus_;
+ ExportedObject* exported_object_;
+};
+
+} // namespace dbus
+
+#endif // DBUS_TEST_SERVICE_H_
« no previous file with comments | « dbus/scoped_dbus_error.h ('k') | dbus/test_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698