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

Side by Side Diff: chrome/browser/policy/cloud_policy_controller.h

Issue 6705031: Send policy blobs to session_manager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix nits Created 9 years, 8 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
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 #ifndef CHROME_BROWSER_POLICY_CLOUD_POLICY_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_POLICY_CONTROLLER_H_
6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_CONTROLLER_H_ 6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_CONTROLLER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "base/task.h" 14 #include "base/task.h"
15 #include "base/time.h" 15 #include "base/time.h"
16 #include "chrome/browser/policy/cloud_policy_identity_strategy.h" 16 #include "chrome/browser/policy/cloud_policy_identity_strategy.h"
17 #include "chrome/browser/policy/configuration_policy_provider.h" 17 #include "chrome/browser/policy/configuration_policy_provider.h"
18 #include "chrome/browser/policy/device_management_backend.h" 18 #include "chrome/browser/policy/device_management_backend.h"
19 #include "chrome/browser/policy/device_token_fetcher.h" 19 #include "chrome/browser/policy/device_token_fetcher.h"
20 20
21 class Profile; 21 class Profile;
22 class TokenService; 22 class TokenService;
23 23
24 namespace policy { 24 namespace policy {
25 25
26 class CloudPolicyCache; 26 class CloudPolicyCacheBase;
27 class DeviceManagementBackend; 27 class DeviceManagementBackend;
28 28
29 // Coordinates the actions of DeviceTokenFetcher, CloudPolicyIdentityStrategy, 29 // Coordinates the actions of DeviceTokenFetcher, CloudPolicyIdentityStrategy,
30 // DeviceManagementBackend, and CloudPolicyCache: calls their methods and 30 // DeviceManagementBackend, and CloudPolicyCache: calls their methods and
31 // listens to their callbacks/notifications. 31 // listens to their callbacks/notifications.
32 class CloudPolicyController 32 class CloudPolicyController
33 : public DeviceManagementBackend::DevicePolicyResponseDelegate, 33 : public DeviceManagementBackend::DevicePolicyResponseDelegate,
34 public DeviceTokenFetcher::Observer, 34 public DeviceTokenFetcher::Observer,
35 public CloudPolicyIdentityStrategy::Observer { 35 public CloudPolicyIdentityStrategy::Observer {
36 public: 36 public:
37 // Takes ownership of |backend|; the other parameters are weak pointers. 37 // Takes ownership of |backend|; the other parameters are weak pointers.
38 CloudPolicyController(CloudPolicyCache* cache, 38 CloudPolicyController(CloudPolicyCacheBase* cache,
39 DeviceManagementBackend* backend, 39 DeviceManagementBackend* backend,
40 DeviceTokenFetcher* token_fetcher, 40 DeviceTokenFetcher* token_fetcher,
41 CloudPolicyIdentityStrategy* identity_strategy); 41 CloudPolicyIdentityStrategy* identity_strategy);
42 virtual ~CloudPolicyController(); 42 virtual ~CloudPolicyController();
43 43
44 // Sets the refresh rate at which to re-fetch policy information. 44 // Sets the refresh rate at which to re-fetch policy information.
45 void SetRefreshRate(int64 refresh_rate_milliseconds); 45 void SetRefreshRate(int64 refresh_rate_milliseconds);
46 46
47 // DevicePolicyResponseDelegate implementation: 47 // DevicePolicyResponseDelegate implementation:
48 virtual void HandlePolicyResponse( 48 virtual void HandlePolicyResponse(
(...skipping 22 matching lines...) Expand all
71 STATE_POLICY_VALID, 71 STATE_POLICY_VALID,
72 // The service returned an error when requesting policy, will retry. 72 // The service returned an error when requesting policy, will retry.
73 STATE_POLICY_ERROR, 73 STATE_POLICY_ERROR,
74 // The service returned an error that is not going to go away soon. 74 // The service returned an error that is not going to go away soon.
75 STATE_POLICY_UNAVAILABLE 75 STATE_POLICY_UNAVAILABLE
76 }; 76 };
77 77
78 friend class CloudPolicyControllerTest; 78 friend class CloudPolicyControllerTest;
79 79
80 // More configurable constructor for use by test cases. 80 // More configurable constructor for use by test cases.
81 CloudPolicyController(CloudPolicyCache* cache, 81 CloudPolicyController(CloudPolicyCacheBase* cache,
82 DeviceManagementBackend* backend, 82 DeviceManagementBackend* backend,
83 DeviceTokenFetcher* token_fetcher, 83 DeviceTokenFetcher* token_fetcher,
84 CloudPolicyIdentityStrategy* identity_strategy, 84 CloudPolicyIdentityStrategy* identity_strategy,
85 int64 policy_refresh_rate_ms, 85 int64 policy_refresh_rate_ms,
86 int policy_refresh_deviation_factor_percent, 86 int policy_refresh_deviation_factor_percent,
87 int64 policy_refresh_deviation_max_ms, 87 int64 policy_refresh_deviation_max_ms,
88 int64 policy_refresh_error_delay_ms); 88 int64 policy_refresh_error_delay_ms);
89 89
90 // Called by constructors to perform shared initialization. 90 // Called by constructors to perform shared initialization.
91 void Initialize(CloudPolicyCache* cache, 91 void Initialize(CloudPolicyCacheBase* cache,
92 DeviceManagementBackend* backend, 92 DeviceManagementBackend* backend,
93 DeviceTokenFetcher* token_fetcher, 93 DeviceTokenFetcher* token_fetcher,
94 CloudPolicyIdentityStrategy* identity_strategy, 94 CloudPolicyIdentityStrategy* identity_strategy,
95 int64 policy_refresh_rate_ms, 95 int64 policy_refresh_rate_ms,
96 int policy_refresh_deviation_factor_percent, 96 int policy_refresh_deviation_factor_percent,
97 int64 policy_refresh_deviation_max_ms, 97 int64 policy_refresh_deviation_max_ms,
98 int64 policy_refresh_error_delay_ms); 98 int64 policy_refresh_error_delay_ms);
99 99
100 // Asks the token fetcher to fetch a new token. 100 // Asks the token fetcher to fetch a new token.
101 void FetchToken(); 101 void FetchToken();
102 102
103 // Sends a request to the device management backend to fetch policy if one 103 // Sends a request to the device management backend to fetch policy if one
104 // isn't already outstanding. 104 // isn't already outstanding.
105 void SendPolicyRequest(); 105 void SendPolicyRequest();
106 106
107 // Called back from the delayed work task. Performs whatever action is 107 // Called back from the delayed work task. Performs whatever action is
108 // required in the current state, e.g. refreshing policy. 108 // required in the current state, e.g. refreshing policy.
109 void DoDelayedWork(); 109 void DoDelayedWork();
110 110
111 // Cancels the delayed work task. 111 // Cancels the delayed work task.
112 void CancelDelayedWork(); 112 void CancelDelayedWork();
113 113
114 // Switches to a new state and triggers any appropriate actions. 114 // Switches to a new state and triggers any appropriate actions.
115 void SetState(ControllerState new_state); 115 void SetState(ControllerState new_state);
116 116
117 // Computes the policy refresh delay to use. 117 // Computes the policy refresh delay to use.
118 int64 GetRefreshDelay(); 118 int64 GetRefreshDelay();
119 119
120 CloudPolicyCache* cache_; 120 CloudPolicyCacheBase* cache_;
121 scoped_ptr<DeviceManagementBackend> backend_; 121 scoped_ptr<DeviceManagementBackend> backend_;
122 CloudPolicyIdentityStrategy* identity_strategy_; 122 CloudPolicyIdentityStrategy* identity_strategy_;
123 DeviceTokenFetcher* token_fetcher_; 123 DeviceTokenFetcher* token_fetcher_;
124 ControllerState state_; 124 ControllerState state_;
125 bool initial_fetch_done_; 125 bool initial_fetch_done_;
126 126
127 int64 policy_refresh_rate_ms_; 127 int64 policy_refresh_rate_ms_;
128 int policy_refresh_deviation_factor_percent_; 128 int policy_refresh_deviation_factor_percent_;
129 int64 policy_refresh_deviation_max_ms_; 129 int64 policy_refresh_deviation_max_ms_;
130 int64 policy_refresh_error_delay_ms_; 130 int64 policy_refresh_error_delay_ms_;
131 int64 effective_policy_refresh_error_delay_ms_; 131 int64 effective_policy_refresh_error_delay_ms_;
132 132
133 CancelableTask* delayed_work_task_; 133 CancelableTask* delayed_work_task_;
134 ScopedRunnableMethodFactory<CloudPolicyController> method_factory_; 134 ScopedRunnableMethodFactory<CloudPolicyController> method_factory_;
135 135
136 DISALLOW_COPY_AND_ASSIGN(CloudPolicyController); 136 DISALLOW_COPY_AND_ASSIGN(CloudPolicyController);
137 }; 137 };
138 138
139 } // namespace policy 139 } // namespace policy
140 140
141 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_CONTROLLER_H_ 141 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_CONTROLLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/policy/cloud_policy_cache_unittest.cc ('k') | chrome/browser/policy/cloud_policy_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698