| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/chromeos/net/network_throttling_observer.h" | 5 #include "chrome/browser/chromeos/net/network_throttling_observer.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 const std::string& pref_name) { | 40 const std::string& pref_name) { |
| 41 DCHECK(pref_name == prefs::kNetworkThrottlingEnabled); | 41 DCHECK(pref_name == prefs::kNetworkThrottlingEnabled); |
| 42 | 42 |
| 43 const base::DictionaryValue* throttling_policy = | 43 const base::DictionaryValue* throttling_policy = |
| 44 local_state_->GetDictionary(prefs::kNetworkThrottlingEnabled); | 44 local_state_->GetDictionary(prefs::kNetworkThrottlingEnabled); |
| 45 | 45 |
| 46 // Default is to disable throttling if the policy is not found. | 46 // Default is to disable throttling if the policy is not found. |
| 47 bool enabled = false; | 47 bool enabled = false; |
| 48 uint32_t upload_rate = 0, download_rate = 0; | 48 uint32_t upload_rate = 0, download_rate = 0; |
| 49 if (throttling_policy) { | 49 if (throttling_policy) { |
| 50 int upload_rate_read = 0; | 50 int upload_rate_read, download_rate_read; |
| 51 int download_rate_read = 0; | |
| 52 | 51 |
| 53 throttling_policy->GetBoolean("enabled", &enabled); | 52 throttling_policy->GetBoolean("enabled", &enabled); |
| 54 | 53 |
| 55 if (throttling_policy->GetInteger("upload_rate_kbits", &upload_rate_read) && | 54 if (throttling_policy->GetInteger("upload_rate_kbits", &upload_rate_read) && |
| 56 upload_rate_read > 0) { | 55 upload_rate_read > 0) { |
| 57 upload_rate = upload_rate_read; | 56 upload_rate = upload_rate_read; |
| 58 } | 57 } |
| 59 | 58 |
| 60 if (throttling_policy->GetInteger("download_rate_kbits", | 59 if (throttling_policy->GetInteger("download_rate_kbits", |
| 61 &download_rate_read) && | 60 &download_rate_read) && |
| 62 download_rate_read > 0) { | 61 download_rate_read > 0) { |
| 63 download_rate = download_rate_read; | 62 download_rate = download_rate_read; |
| 64 } | 63 } |
| 65 } | 64 } |
| 66 NetworkHandler::Get()->network_state_handler()->SetNetworkThrottlingStatus( | 65 NetworkHandler::Get()->network_state_handler()->SetNetworkThrottlingStatus( |
| 67 enabled, upload_rate, download_rate); | 66 enabled, upload_rate, download_rate); |
| 68 } | 67 } |
| 69 | 68 |
| 70 } // namespace chromeos | 69 } // namespace chromeos |
| OLD | NEW |