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

Side by Side Diff: chromeos/network/network_state_handler.cc

Issue 2364703002: Add network throttling as an enterprise policy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add network bandwidth throttling as an enterprise policy Created 4 years, 2 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chromeos/network/network_state_handler.h" 5 #include "chromeos/network/network_state_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility>
Andrew T Wilson (Slow) 2016/10/21 13:27:30 Why is this here?
kirtika1 2016/10/23 00:04:49 These and other includes were added to silence cpp
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/format_macros.h" 11 #include "base/format_macros.h"
11 #include "base/guid.h" 12 #include "base/guid.h"
12 #include "base/json/json_string_value_serializer.h" 13 #include "base/json/json_string_value_serializer.h"
13 #include "base/json/json_writer.h" 14 #include "base/json/json_writer.h"
14 #include "base/location.h" 15 #include "base/location.h"
15 #include "base/logging.h" 16 #include "base/logging.h"
16 #include "base/memory/ptr_util.h" 17 #include "base/memory/ptr_util.h"
17 #include "base/metrics/histogram_macros.h" 18 #include "base/metrics/histogram_macros.h"
19 #include "base/strings/string_number_conversions.h"
18 #include "base/strings/string_util.h" 20 #include "base/strings/string_util.h"
19 #include "base/strings/stringprintf.h" 21 #include "base/strings/stringprintf.h"
20 #include "base/values.h" 22 #include "base/values.h"
21 #include "chromeos/network/device_state.h" 23 #include "chromeos/network/device_state.h"
22 #include "chromeos/network/network_event_log.h" 24 #include "chromeos/network/network_event_log.h"
23 #include "chromeos/network/network_state.h" 25 #include "chromeos/network/network_state.h"
24 #include "chromeos/network/network_state_handler_observer.h" 26 #include "chromeos/network/network_state_handler_observer.h"
25 #include "third_party/cros_system_api/dbus/service_constants.h" 27 #include "third_party/cros_system_api/dbus/service_constants.h"
26 28
27 namespace chromeos { 29 namespace chromeos {
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 const std::string& check_portal_list) { 379 const std::string& check_portal_list) {
378 NET_LOG_EVENT("SetCheckPortalList", check_portal_list); 380 NET_LOG_EVENT("SetCheckPortalList", check_portal_list);
379 shill_property_handler_->SetCheckPortalList(check_portal_list); 381 shill_property_handler_->SetCheckPortalList(check_portal_list);
380 } 382 }
381 383
382 void NetworkStateHandler::SetWakeOnLanEnabled(bool enabled) { 384 void NetworkStateHandler::SetWakeOnLanEnabled(bool enabled) {
383 NET_LOG_EVENT("SetWakeOnLanEnabled", enabled ? "true" : "false"); 385 NET_LOG_EVENT("SetWakeOnLanEnabled", enabled ? "true" : "false");
384 shill_property_handler_->SetWakeOnLanEnabled(enabled); 386 shill_property_handler_->SetWakeOnLanEnabled(enabled);
385 } 387 }
386 388
389 void NetworkStateHandler::SetNetworkThrottlingStatus(
390 bool enabled,
391 uint32_t upload_rate_kbits,
392 uint32_t download_rate_kbits) {
393 NET_LOG_EVENT("SetNetworkThrottlingStatus",
394 enabled ? ("true :" + base::IntToString(upload_rate_kbits) +
395 " , " + base::IntToString(download_rate_kbits))
Andrew T Wilson (Slow) 2016/10/21 13:27:30 nit, typically put a space after the comma but not
kirtika1 2016/10/23 00:04:49 Done.
396 : "false");
397 shill_property_handler_->SetNetworkThrottlingStatus(
398 enabled, upload_rate_kbits, download_rate_kbits);
399 }
400
387 const NetworkState* NetworkStateHandler::GetEAPForEthernet( 401 const NetworkState* NetworkStateHandler::GetEAPForEthernet(
388 const std::string& service_path) { 402 const std::string& service_path) {
389 const NetworkState* network = GetNetworkState(service_path); 403 const NetworkState* network = GetNetworkState(service_path);
390 if (!network) { 404 if (!network) {
391 NET_LOG_ERROR("GetEAPForEthernet", "Unknown service path " + service_path); 405 NET_LOG_ERROR("GetEAPForEthernet", "Unknown service path " + service_path);
392 return nullptr; 406 return nullptr;
393 } 407 }
394 if (network->type() != shill::kTypeEthernet) { 408 if (network->type() != shill::kTypeEthernet) {
395 NET_LOG_ERROR("GetEAPForEthernet", "Not of type Ethernet: " + service_path); 409 NET_LOG_ERROR("GetEAPForEthernet", "Not of type Ethernet: " + service_path);
396 return nullptr; 410 return nullptr;
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 if (type.MatchesType(shill::kTypeBluetooth)) 1000 if (type.MatchesType(shill::kTypeBluetooth))
987 technologies.emplace_back(shill::kTypeBluetooth); 1001 technologies.emplace_back(shill::kTypeBluetooth);
988 if (type.MatchesType(shill::kTypeVPN)) 1002 if (type.MatchesType(shill::kTypeVPN))
989 technologies.emplace_back(shill::kTypeVPN); 1003 technologies.emplace_back(shill::kTypeVPN);
990 1004
991 CHECK_GT(technologies.size(), 0ul); 1005 CHECK_GT(technologies.size(), 0ul);
992 return technologies; 1006 return technologies;
993 } 1007 }
994 1008
995 } // namespace chromeos 1009 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698