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

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: 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
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/observer_list.h" 12 #include "base/observer_list.h"
13 #include "base/scoped_ptr.h" 13 #include "base/scoped_ptr.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 16 matching lines...) Expand all
65 STATE_TOKEN_VALID, 65 STATE_TOKEN_VALID,
66 // Policy information is available and valid. 66 // Policy information is available and valid.
67 STATE_POLICY_VALID, 67 STATE_POLICY_VALID,
68 // The service returned an error when requesting policy, ask again later. 68 // The service returned an error when requesting policy, ask again later.
69 STATE_POLICY_ERROR, 69 STATE_POLICY_ERROR,
70 }; 70 };
71 71
72 friend class CloudPolicyControllerTest; 72 friend class CloudPolicyControllerTest;
73 73
74 // More configurable constructor for use by test cases. 74 // More configurable constructor for use by test cases.
75 CloudPolicyController(CloudPolicyCache* cache, 75 CloudPolicyController(CloudPolicyCacheBase* cache,
76 DeviceManagementBackend* backend, 76 DeviceManagementBackend* backend,
77 DeviceTokenFetcher* token_fetcher, 77 DeviceTokenFetcher* token_fetcher,
78 CloudPolicyIdentityStrategy* identity_strategy, 78 CloudPolicyIdentityStrategy* identity_strategy,
79 int64 policy_refresh_rate_ms, 79 int64 policy_refresh_rate_ms,
80 int policy_refresh_deviation_factor_percent, 80 int policy_refresh_deviation_factor_percent,
81 int64 policy_refresh_deviation_max_ms, 81 int64 policy_refresh_deviation_max_ms,
82 int64 policy_refresh_error_delay_ms); 82 int64 policy_refresh_error_delay_ms);
83 83
84 // Called by constructors to perform shared initialization. 84 // Called by constructors to perform shared initialization.
85 void Initialize(CloudPolicyCache* cache, 85 void Initialize(CloudPolicyCacheBase* cache,
86 DeviceManagementBackend* backend, 86 DeviceManagementBackend* backend,
87 DeviceTokenFetcher* token_fetcher, 87 DeviceTokenFetcher* token_fetcher,
88 CloudPolicyIdentityStrategy* identity_strategy, 88 CloudPolicyIdentityStrategy* identity_strategy,
89 int64 policy_refresh_rate_ms, 89 int64 policy_refresh_rate_ms,
90 int policy_refresh_deviation_factor_percent, 90 int policy_refresh_deviation_factor_percent,
91 int64 policy_refresh_deviation_max_ms, 91 int64 policy_refresh_deviation_max_ms,
92 int64 policy_refresh_error_delay_ms); 92 int64 policy_refresh_error_delay_ms);
93 93
94 // Asks the token fetcher to fetch a new token. 94 // Asks the token fetcher to fetch a new token.
95 void FetchToken(); 95 void FetchToken();
96 96
97 // Sends a request to the device management backend to fetch policy if one 97 // Sends a request to the device management backend to fetch policy if one
98 // isn't already outstanding. 98 // isn't already outstanding.
99 void SendPolicyRequest(); 99 void SendPolicyRequest();
100 100
101 // Called back from the delayed work task. Performs whatever action is 101 // Called back from the delayed work task. Performs whatever action is
102 // required in the current state, e.g. refreshing policy. 102 // required in the current state, e.g. refreshing policy.
103 void DoDelayedWork(); 103 void DoDelayedWork();
104 104
105 // Cancels the delayed work task. 105 // Cancels the delayed work task.
106 void CancelDelayedWork(); 106 void CancelDelayedWork();
107 107
108 // Switches to a new state and triggers any appropriate actions. 108 // Switches to a new state and triggers any appropriate actions.
109 void SetState(ControllerState new_state); 109 void SetState(ControllerState new_state);
110 110
111 // Computes the policy refresh delay to use. 111 // Computes the policy refresh delay to use.
112 int64 GetRefreshDelay(); 112 int64 GetRefreshDelay();
113 113
114 CloudPolicyCache* cache_; 114 CloudPolicyCacheBase* cache_;
115 scoped_ptr<DeviceManagementBackend> backend_; 115 scoped_ptr<DeviceManagementBackend> backend_;
116 CloudPolicyIdentityStrategy* identity_strategy_; 116 CloudPolicyIdentityStrategy* identity_strategy_;
117 DeviceTokenFetcher* token_fetcher_; 117 DeviceTokenFetcher* token_fetcher_;
118 ControllerState state_; 118 ControllerState state_;
119 bool initial_fetch_done_; 119 bool initial_fetch_done_;
120 120
121 int64 policy_refresh_rate_ms_; 121 int64 policy_refresh_rate_ms_;
122 int policy_refresh_deviation_factor_percent_; 122 int policy_refresh_deviation_factor_percent_;
123 int64 policy_refresh_deviation_max_ms_; 123 int64 policy_refresh_deviation_max_ms_;
124 int64 policy_refresh_error_delay_ms_; 124 int64 policy_refresh_error_delay_ms_;
125 int64 effective_policy_refresh_error_delay_ms_; 125 int64 effective_policy_refresh_error_delay_ms_;
126 126
127 CancelableTask* delayed_work_task_; 127 CancelableTask* delayed_work_task_;
128 ScopedRunnableMethodFactory<CloudPolicyController> method_factory_; 128 ScopedRunnableMethodFactory<CloudPolicyController> method_factory_;
129 129
130 DISALLOW_COPY_AND_ASSIGN(CloudPolicyController); 130 DISALLOW_COPY_AND_ASSIGN(CloudPolicyController);
131 }; 131 };
132 132
133 } // namespace policy 133 } // namespace policy
134 134
135 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_CONTROLLER_H_ 135 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698