| OLD | NEW |
| 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 #include "chrome/browser/policy/cloud_policy_subsystem.h" | 5 #include "chrome/browser/policy/cloud_policy_subsystem.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "chrome/browser/policy/cloud_policy_cache_base.h" | 11 #include "chrome/browser/policy/cloud_policy_cache_base.h" |
| 12 #include "chrome/browser/policy/cloud_policy_controller.h" | 12 #include "chrome/browser/policy/cloud_policy_controller.h" |
| 13 #include "chrome/browser/policy/cloud_policy_identity_strategy.h" | 13 #include "chrome/browser/policy/cloud_policy_identity_strategy.h" |
| 14 #include "chrome/browser/policy/configuration_policy_provider.h" | 14 #include "chrome/browser/policy/configuration_policy_provider.h" |
| 15 #include "chrome/browser/policy/device_management_service.h" | 15 #include "chrome/browser/policy/device_management_service.h" |
| 16 #include "chrome/browser/policy/device_token_fetcher.h" | 16 #include "chrome/browser/policy/device_token_fetcher.h" |
| 17 #include "chrome/browser/policy/policy_notifier.h" | 17 #include "chrome/browser/policy/policy_notifier.h" |
| 18 #include "chrome/browser/prefs/pref_service.h" | 18 #include "chrome/browser/prefs/pref_service.h" |
| 19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 20 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 21 #include "content/common/notification_details.h" | 21 #include "content/common/notification_details.h" |
| 22 #include "content/common/notification_source.h" | 22 #include "content/common/notification_source.h" |
| 23 #include "content/common/notification_type.h" | 23 #include "content/common/notification_type.h" |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 // Default refresh rate. | 27 // Default refresh rate. |
| 28 const int kDefaultPolicyRefreshRateMs = 3 * 60 * 60 * 1000; // 3 hours. | 28 const int64 kDefaultPolicyRefreshRateMs = 3 * 60 * 60 * 1000; // 3 hours. |
| 29 | 29 |
| 30 // Refresh rate sanity interval bounds. | 30 // Refresh rate sanity interval bounds. |
| 31 const int64 kPolicyRefreshRateMinMs = 30 * 60 * 1000; // 30 minutes | 31 const int64 kPolicyRefreshRateMinMs = 30 * 60 * 1000; // 30 minutes |
| 32 const int64 kPolicyRefreshRateMaxMs = 24 * 60 * 60 * 1000; // 1 day | 32 const int64 kPolicyRefreshRateMaxMs = 24 * 60 * 60 * 1000; // 1 day |
| 33 | 33 |
| 34 } // namespace | 34 } // namespace |
| 35 | 35 |
| 36 namespace policy { | 36 namespace policy { |
| 37 | 37 |
| 38 CloudPolicySubsystem::ObserverRegistrar::ObserverRegistrar( | 38 CloudPolicySubsystem::ObserverRegistrar::ObserverRegistrar( |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 void CloudPolicySubsystem::OnIPAddressChanged() { | 82 void CloudPolicySubsystem::OnIPAddressChanged() { |
| 83 if (state() == CloudPolicySubsystem::NETWORK_ERROR && | 83 if (state() == CloudPolicySubsystem::NETWORK_ERROR && |
| 84 cloud_policy_controller_.get()) { | 84 cloud_policy_controller_.get()) { |
| 85 cloud_policy_controller_->Retry(); | 85 cloud_policy_controller_->Retry(); |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 | 88 |
| 89 void CloudPolicySubsystem::Initialize( | 89 void CloudPolicySubsystem::Initialize( |
| 90 PrefService* prefs, | 90 PrefService* prefs, |
| 91 int delay_milliseconds) { | 91 int64 delay_milliseconds) { |
| 92 DCHECK(!prefs_); | 92 DCHECK(!prefs_); |
| 93 prefs_ = prefs; | 93 prefs_ = prefs; |
| 94 | 94 |
| 95 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 95 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 96 if (command_line->HasSwitch(switches::kDeviceManagementUrl)) { | 96 if (command_line->HasSwitch(switches::kDeviceManagementUrl)) { |
| 97 DCHECK(!cloud_policy_controller_.get()); | 97 DCHECK(!cloud_policy_controller_.get()); |
| 98 cloud_policy_controller_.reset( | 98 cloud_policy_controller_.reset( |
| 99 new CloudPolicyController(device_management_service_.get(), | 99 new CloudPolicyController(device_management_service_.get(), |
| 100 cloud_policy_cache_.get(), | 100 cloud_policy_cache_.get(), |
| 101 device_token_fetcher_.get(), | 101 device_token_fetcher_.get(), |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 policy_refresh_rate_.GetPrefName() == | 171 policy_refresh_rate_.GetPrefName() == |
| 172 *(Details<std::string>(details).ptr()) && | 172 *(Details<std::string>(details).ptr()) && |
| 173 prefs_ == Source<PrefService>(source).ptr()) { | 173 prefs_ == Source<PrefService>(source).ptr()) { |
| 174 UpdatePolicyRefreshRate(); | 174 UpdatePolicyRefreshRate(); |
| 175 } else { | 175 } else { |
| 176 NOTREACHED(); | 176 NOTREACHED(); |
| 177 } | 177 } |
| 178 } | 178 } |
| 179 | 179 |
| 180 void CloudPolicySubsystem::ScheduleServiceInitialization( | 180 void CloudPolicySubsystem::ScheduleServiceInitialization( |
| 181 int delay_milliseconds) { | 181 int64 delay_milliseconds) { |
| 182 if (device_management_service_.get()) | 182 if (device_management_service_.get()) |
| 183 device_management_service_->ScheduleInitialization(delay_milliseconds); | 183 device_management_service_->ScheduleInitialization(delay_milliseconds); |
| 184 } | 184 } |
| 185 | 185 |
| 186 } // namespace policy | 186 } // namespace policy |
| OLD | NEW |