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

Side by Side 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, 9 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
(Empty)
1 // Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef _VPN_MANAGER_SERVICE_MANAGER_H_
6 #define _VPN_MANAGER_SERVICE_MANAGER_H_
7
8 #include <string>
9
10 #include "base/file_path.h"
11 #include "gtest/gtest_prod.h" // for FRIEND_TEST
12
13 class ServiceManager {
14 public:
15 ServiceManager(const std::string& service_name);
16 virtual ~ServiceManager();
17
18 // 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.
19 static void Initialize();
20
21 // Call to initiate this service. If starting fails immediately this
22 // returns false. If something fails after this returns, OnStopped
23 // willl be called.
24 virtual bool Start() = 0;
25
26 // Callback when this service has successfully started.
27 virtual void OnStarted();
28
29 // Call to stop this service. Must not be called on a separate
30 // thread from Start().
31 virtual void Stop() = 0;
32
33 // Callback when this service has stopped after having started
34 // successfully. |was_error| indicates if an error occurred.
35 virtual void OnStopped(bool was_error);
36
37 // Queries if this service is currently running.
38 bool is_running() {
39 return is_running_;
40 }
41
42 // Queries if this service was once running and is now stopped.
43 bool was_stopped() {
44 return was_stopped_;
45 }
46
47 // Set up layering between two service managers |outer| and |inner|.
48 static void SetLayerOrder(ServiceManager* outer,
49 ServiceManager* inner) {
50 outer->inner_service_ = inner;
51 inner->outer_service_ = outer;
52 }
53
54 const std::string& service_name() {
55 return service_name_;
56 }
57
58 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.
59
60 protected:
61 friend class IpsecManagerTest;
62 friend class ServiceManagerTest;
63 FRIEND_TEST(ServiceManagerTest, Initialize);
64 FRIEND_TEST(ServiceManagerTest, OnStoppedFromFailure);
65 FRIEND_TEST(ServiceManagerTest, OnStoppedFromSuccess);
66
67 // Removes temporary directory.
68 static void DeleteTemp();
69
70 // Indicates if this service is currently running.
71 bool is_running_;
72
73 // Indicates if this service was running and is now stopped.
74 bool was_stopped_;
75
76 // Pointer to the next layer or NULL if innermost.
77 ServiceManager* inner_service_;
78
79 // Pointer to the outer layer or NULL if outermost.
80 ServiceManager* outer_service_;
81
82 // Name of this service.
83 std::string service_name_;
84
85 // Location to put temporary files - will be on cryptohome.
86 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
87 };
88
89 #endif // _VPN_MANAGER_SERVICE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698