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

Unified Diff: service_manager.h

Issue 6508016: vpn-manager: Add l2tp/ipsec vpn manager (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vpn-manager.git@master
Patch Set: tweak Created 9 years, 10 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
Index: service_manager.h
diff --git a/service_manager.h b/service_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..d1bffd605c24e390320e69405f479addcdd0e46f
--- /dev/null
+++ b/service_manager.h
@@ -0,0 +1,89 @@
+// Copyright (c) 2011 The Chromium OS 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 _VPN_MANAGER_SERVICE_MANAGER_H_
+#define _VPN_MANAGER_SERVICE_MANAGER_H_
+
+#include <string>
+
+#include "base/file_path.h"
+#include "gtest/gtest_prod.h" // for FRIEND_TEST
+
+class ServiceManager {
+ public:
+ ServiceManager(const std::string& service_name);
+ virtual ~ServiceManager();
+
+ // Initialize ServiceManager.
petkov 2011/03/04 18:42:56 always succeeds?
kmixter1 2011/03/05 02:48:59 No, but if it returns it has.
+ static void Initialize();
+
+ // Call to initiate this service. If starting fails immediately this
+ // returns false. If something fails after this returns, OnStopped
+ // willl be called.
+ virtual bool Start() = 0;
+
+ // Callback when this service has successfully started.
+ virtual void OnStarted();
+
+ // Call to stop this service. Must not be called on a separate
+ // thread from Start().
+ virtual void Stop() = 0;
+
+ // Callback when this service has stopped after having started
+ // successfully. |was_error| indicates if an error occurred.
+ virtual void OnStopped(bool was_error);
+
+ // Queries if this service is currently running.
+ bool is_running() {
+ return is_running_;
+ }
+
+ // Queries if this service was once running and is now stopped.
+ bool was_stopped() {
+ return was_stopped_;
+ }
+
+ // Set up layering between two service managers |outer| and |inner|.
+ static void SetLayerOrder(ServiceManager* outer,
+ ServiceManager* inner) {
+ outer->inner_service_ = inner;
+ inner->outer_service_ = outer;
+ }
+
+ const std::string& service_name() {
+ return service_name_;
+ }
+
+ static void WriteFdToSyslog(int fd, const char* prefix);
petkov 2011/03/04 18:42:56 what does this do?
kmixter1 2011/03/05 02:48:59 Done.
+
+ protected:
+ friend class IpsecManagerTest;
+ friend class ServiceManagerTest;
+ FRIEND_TEST(ServiceManagerTest, Initialize);
+ FRIEND_TEST(ServiceManagerTest, OnStoppedFromFailure);
+ FRIEND_TEST(ServiceManagerTest, OnStoppedFromSuccess);
+
+ // Removes temporary directory.
+ static void DeleteTemp();
+
+ // Indicates if this service is currently running.
+ bool is_running_;
+
+ // Indicates if this service was running and is now stopped.
+ bool was_stopped_;
+
+ // Pointer to the next layer or NULL if innermost.
+ ServiceManager* inner_service_;
+
+ // Pointer to the outer layer or NULL if outermost.
+ ServiceManager* outer_service_;
+
+ // Name of this service.
+ std::string service_name_;
+
+ // Location to put temporary files - will be on cryptohome.
+ static FilePath temp_path_;
petkov 2011/03/04 18:42:56 static variables of class type are forbidden
kmixter1 2011/03/05 02:48:59 Replaced with point to FilePath which is now clean
+};
+
+#endif // _VPN_MANAGER_SERVICE_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698