OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium 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 CHROME_BROWSER_POLICY_CLOUD_REMOTE_COMMANDS_INVALIDATOR_BASE_H_ | |
6 #define CHROME_BROWSER_POLICY_CLOUD_REMOTE_COMMANDS_INVALIDATOR_BASE_H_ | |
7 | |
8 #include <string> | |
bartfab (slow)
2015/05/15 13:28:08
Nit: Not used (only used in overriden method decla
binjin
2015/05/15 14:50:39
Done.
| |
9 | |
10 #include "base/macros.h" | |
11 #include "base/memory/ref_counted.h" | |
12 #include "base/memory/weak_ptr.h" | |
13 #include "base/threading/thread_checker.h" | |
14 #include "components/invalidation/invalidation.h" | |
bartfab (slow)
2015/05/15 13:28:08
Nit: Not used.
binjin
2015/05/15 14:50:39
Done.
| |
15 #include "components/invalidation/invalidation_handler.h" | |
16 #include "policy/proto/device_management_backend.pb.h" | |
17 | |
18 namespace base { | |
19 class SequencedTaskRunner; | |
20 } // namespace base | |
21 | |
22 namespace invalidation { | |
23 class InvalidationService; | |
24 } // namespace invalidation | |
25 | |
26 namespace policy { | |
27 | |
28 class CloudPolicyCore; | |
bartfab (slow)
2015/05/15 13:28:08
Nit: Not used.
binjin
2015/05/15 14:50:39
Done.
| |
29 | |
30 // XXX | |
bartfab (slow)
2015/05/15 13:28:08
I presume you will add comments before this lands
binjin
2015/05/15 14:50:39
Done.
| |
31 class RemoteCommandsInvalidatorBase : public syncer::InvalidationHandler { | |
32 public: | |
33 // XXX | |
34 RemoteCommandsInvalidatorBase( | |
bartfab (slow)
2015/05/15 13:28:08
Nit: explicit.
binjin
2015/05/15 14:50:39
Done.
| |
35 const scoped_refptr<base::SequencedTaskRunner>& task_runner); | |
bartfab (slow)
2015/05/15 13:28:08
What is this |task_runner| used for? If it is used
binjin
2015/05/15 14:50:39
It's used to post |DoRemoteCommandsFetch|, and sub
bartfab (slow)
2015/05/15 15:37:12
The MessageLoopProxy you are using in that class i
| |
36 ~RemoteCommandsInvalidatorBase() override; | |
37 | |
38 // XXX | |
39 void Initialize(invalidation::InvalidationService* invalidation_service); | |
40 | |
41 // XXX | |
42 void Shutdown(); | |
43 | |
44 // XXX | |
45 void Start(); | |
46 | |
47 // XXX | |
48 void Stop(); | |
49 | |
50 // Helpful accessors. | |
51 invalidation::InvalidationService* invalidation_service() { | |
52 return invalidation_service_; | |
53 } | |
54 bool invalidations_enabled() { return invalidations_enabled_; } | |
55 | |
56 // syncer::InvalidationHandler: | |
57 void OnInvalidatorStateChange(syncer::InvalidatorState state) override; | |
58 void OnIncomingInvalidation( | |
59 const syncer::ObjectIdInvalidationMap& invalidation_map) override; | |
60 std::string GetOwnerName() const override; | |
61 | |
62 protected: | |
63 virtual void OnInitialize() {} | |
bartfab (slow)
2015/05/15 13:28:08
Nit 1: The style guide forbids inlining virtual me
binjin
2015/05/15 14:50:39
Done.
| |
64 virtual void OnShutdown() {} | |
65 virtual void OnStart() {} | |
66 virtual void OnStop() {} | |
67 virtual void DoRemoteCommandsFetch() = 0; | |
68 | |
69 // XXX | |
70 void ReloadPolicyData(const enterprise_management::PolicyData* policy); | |
71 | |
72 private: | |
73 // Registers the given object with the invalidation service. | |
74 void Register(const invalidation::ObjectId& object_id); | |
bartfab (slow)
2015/05/15 13:28:08
Nit: #include "google/cacheinvalidation/include/ty
binjin
2015/05/15 14:50:39
Done.
| |
75 | |
76 // Unregisters the current object with the invalidation service. | |
77 void Unregister(); | |
78 | |
79 // Updates invalidations_enabled_ and calls the invalidation handler if the | |
bartfab (slow)
2015/05/15 13:28:08
Which handler are you talking about here? I cannot
binjin
2015/05/15 14:50:39
Done.
| |
80 // value changed. | |
81 void UpdateInvalidationsEnabled(); | |
82 | |
83 // The state of the object. | |
84 enum State { | |
85 SHUT_DOWN, | |
86 STOPPED, | |
87 STARTED, | |
88 }; | |
89 State state_; | |
90 | |
91 // Schedules delayed tasks. | |
92 const scoped_refptr<base::SequencedTaskRunner> task_runner_; | |
93 | |
94 // The invalidation service. | |
95 invalidation::InvalidationService* invalidation_service_ = nullptr; | |
96 | |
97 // Whether the invalidator currently has the ability to receive invalidations. | |
98 // This is true if the invalidation service is enabled and the invalidator | |
99 // has registered for a remote commands object. | |
100 bool invalidations_enabled_ = false; | |
101 | |
102 // Whether the invalidation service is currently enabled. | |
103 bool invalidation_service_enabled_ = false; | |
104 | |
105 // Whether this object has registered for remote commands invalidations. | |
106 bool is_registered_ = false; | |
107 | |
108 // The object id representing the remote commands in the invalidation service. | |
109 invalidation::ObjectId object_id_; | |
110 | |
111 // A thread checker to make sure that callbacks are invoked on the correct | |
112 // thread. | |
113 base::ThreadChecker thread_checker_; | |
114 | |
115 // WeakPtrFactory used to create callbacks to this object. | |
116 base::WeakPtrFactory<RemoteCommandsInvalidatorBase> weak_factory_; | |
117 | |
118 DISALLOW_COPY_AND_ASSIGN(RemoteCommandsInvalidatorBase); | |
119 }; | |
120 | |
121 } // namespace policy | |
122 | |
123 #endif // CHROME_BROWSER_POLICY_CLOUD_REMOTE_COMMANDS_INVALIDATOR_BASE_H_ | |
OLD | NEW |