| OLD | NEW |
| 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 #ifndef CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ | 6 #define CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/memory/scoped_vector.h" | |
| 17 #include "base/memory/singleton.h" | 16 #include "base/memory/singleton.h" |
| 18 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 19 #include "base/observer_list.h" | 18 #include "base/observer_list.h" |
| 20 #include "base/string16.h" | |
| 21 #include "base/timer.h" | 19 #include "base/timer.h" |
| 22 #include "chrome/browser/chromeos/cros/cros_network_functions.h" | 20 #include "chrome/browser/chromeos/cros/cros_network_functions.h" |
| 23 #include "chrome/browser/chromeos/cros/network_constants.h" | 21 #include "chrome/browser/chromeos/cros/network_constants.h" |
| 24 #include "chrome/browser/chromeos/cros/network_ui_data.h" | 22 #include "chrome/browser/chromeos/cros/network_ui_data.h" |
| 25 #include "googleurl/src/gurl.h" | 23 #include "googleurl/src/gurl.h" |
| 26 | 24 |
| 27 namespace base { | 25 namespace base { |
| 28 class DictionaryValue; | 26 class DictionaryValue; |
| 29 class Value; | 27 class Value; |
| 30 } // namespace base | 28 } // namespace base |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 std::string language; | 64 std::string language; |
| 67 | 65 |
| 68 CellularApn(); | 66 CellularApn(); |
| 69 CellularApn(const std::string& apn, const std::string& network_id, | 67 CellularApn(const std::string& apn, const std::string& network_id, |
| 70 const std::string& username, const std::string& password); | 68 const std::string& username, const std::string& password); |
| 71 ~CellularApn(); | 69 ~CellularApn(); |
| 72 void Set(const base::DictionaryValue& dict); | 70 void Set(const base::DictionaryValue& dict); |
| 73 }; | 71 }; |
| 74 typedef std::vector<CellularApn> CellularApnList; | 72 typedef std::vector<CellularApn> CellularApnList; |
| 75 | 73 |
| 76 // Cellular network is considered low data when less than 60 minues. | |
| 77 static const int kCellularDataLowSecs = 60 * 60; | |
| 78 | |
| 79 // Cellular network is considered low data when less than 30 minues. | |
| 80 static const int kCellularDataVeryLowSecs = 30 * 60; | |
| 81 | |
| 82 // Cellular network is considered low data when less than 100MB. | |
| 83 static const int kCellularDataLowBytes = 100 * 1024 * 1024; | |
| 84 | |
| 85 // Cellular network is considered very low data when less than 50MB. | |
| 86 static const int kCellularDataVeryLowBytes = 50 * 1024 * 1024; | |
| 87 | |
| 88 // The value of priority if it is not set. | 74 // The value of priority if it is not set. |
| 89 const int kPriorityNotSet = 0; | 75 const int kPriorityNotSet = 0; |
| 90 // The value of priority if network is preferred. | 76 // The value of priority if network is preferred. |
| 91 const int kPriorityPreferred = 1; | 77 const int kPriorityPreferred = 1; |
| 92 | 78 |
| 93 // Contains data related to the flimflam.Device interface, | 79 // Contains data related to the flimflam.Device interface, |
| 94 // e.g. ethernet, wifi, cellular. | 80 // e.g. ethernet, wifi, cellular. |
| 95 // TODO(dpolukhin): refactor to make base class and device specific derivatives. | 81 // TODO(dpolukhin): refactor to make base class and device specific derivatives. |
| 96 class NetworkDevice { | 82 class NetworkDevice { |
| 97 public: | 83 public: |
| (...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 | 780 |
| 795 // The friend parsers use this. | 781 // The friend parsers use this. |
| 796 void set_strength(int strength) { strength_ = strength; } | 782 void set_strength(int strength) { strength_ = strength; } |
| 797 | 783 |
| 798 int strength_; // 0-100 | 784 int strength_; // 0-100 |
| 799 | 785 |
| 800 DISALLOW_COPY_AND_ASSIGN(WirelessNetwork); | 786 DISALLOW_COPY_AND_ASSIGN(WirelessNetwork); |
| 801 }; | 787 }; |
| 802 | 788 |
| 803 // Class for networks of TYPE_CELLULAR. | 789 // Class for networks of TYPE_CELLULAR. |
| 804 class CellularDataPlan; | |
| 805 | |
| 806 class CellularNetwork : public WirelessNetwork { | 790 class CellularNetwork : public WirelessNetwork { |
| 807 public: | 791 public: |
| 808 enum DataLeft { | 792 enum DataLeft { |
| 809 DATA_UNKNOWN, | 793 DATA_UNKNOWN, |
| 810 DATA_NORMAL, | 794 DATA_NORMAL, |
| 811 DATA_LOW, | 795 DATA_LOW, |
| 812 DATA_VERY_LOW, | 796 DATA_VERY_LOW, |
| 813 DATA_NONE | 797 DATA_NONE |
| 814 }; | 798 }; |
| 815 | 799 |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 // Passphrase set by user (stored for UI). | 1119 // Passphrase set by user (stored for UI). |
| 1136 std::string user_passphrase_; | 1120 std::string user_passphrase_; |
| 1137 | 1121 |
| 1138 // Weak pointer factory for wrapping pointers to this network in callbacks. | 1122 // Weak pointer factory for wrapping pointers to this network in callbacks. |
| 1139 base::WeakPtrFactory<WifiNetwork> weak_pointer_factory_; | 1123 base::WeakPtrFactory<WifiNetwork> weak_pointer_factory_; |
| 1140 | 1124 |
| 1141 DISALLOW_COPY_AND_ASSIGN(WifiNetwork); | 1125 DISALLOW_COPY_AND_ASSIGN(WifiNetwork); |
| 1142 }; | 1126 }; |
| 1143 typedef std::vector<WifiNetwork*> WifiNetworkVector; | 1127 typedef std::vector<WifiNetwork*> WifiNetworkVector; |
| 1144 | 1128 |
| 1145 // Cellular Data Plan management. | |
| 1146 class CellularDataPlan { | |
| 1147 public: | |
| 1148 CellularDataPlan(); | |
| 1149 explicit CellularDataPlan(const CellularDataPlanInfo &plan); | |
| 1150 ~CellularDataPlan(); | |
| 1151 | |
| 1152 // Formats cellular plan description. | |
| 1153 string16 GetPlanDesciption() const; | |
| 1154 // Evaluates cellular plans status and returns warning string if it is near | |
| 1155 // expiration. | |
| 1156 string16 GetRemainingWarning() const; | |
| 1157 // Formats remaining plan data description. | |
| 1158 string16 GetDataRemainingDesciption() const; | |
| 1159 // Formats plan expiration description. | |
| 1160 string16 GetPlanExpiration() const; | |
| 1161 // Formats plan usage info. | |
| 1162 string16 GetUsageInfo() const; | |
| 1163 // Returns a unique string for this plan that can be used for comparisons. | |
| 1164 std::string GetUniqueIdentifier() const; | |
| 1165 base::TimeDelta remaining_time() const; | |
| 1166 int64 remaining_minutes() const; | |
| 1167 // Returns plan data remaining in bytes. | |
| 1168 int64 remaining_data() const; | |
| 1169 // TODO(stevenjb): Make these private with accessors and properly named. | |
| 1170 std::string plan_name; | |
| 1171 CellularDataPlanType plan_type; | |
| 1172 base::Time update_time; | |
| 1173 base::Time plan_start_time; | |
| 1174 base::Time plan_end_time; | |
| 1175 int64 plan_data_bytes; | |
| 1176 int64 data_bytes_used; | |
| 1177 }; | |
| 1178 typedef ScopedVector<CellularDataPlan> CellularDataPlanVector; | |
| 1179 | |
| 1180 // Geolocation data. | 1129 // Geolocation data. |
| 1181 struct CellTower { | 1130 struct CellTower { |
| 1182 CellTower(); | 1131 CellTower(); |
| 1183 | 1132 |
| 1184 enum RadioType { | 1133 enum RadioType { |
| 1185 RADIOTYPE_GSM, | 1134 RADIOTYPE_GSM, |
| 1186 RADIOTYPE_CDMA, | 1135 RADIOTYPE_CDMA, |
| 1187 RADIOTYPE_WCDMA, | 1136 RADIOTYPE_WCDMA, |
| 1188 } radio_type; // GSM/WCDMA CDMA | 1137 } radio_type; // GSM/WCDMA CDMA |
| 1189 int mobile_country_code; // MCC MCC | 1138 int mobile_country_code; // MCC MCC |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1647 const std::string& service_path) = 0; | 1596 const std::string& service_path) = 0; |
| 1648 | 1597 |
| 1649 // Factory function, creates a new instance and returns ownership. | 1598 // Factory function, creates a new instance and returns ownership. |
| 1650 // For normal usage, access the singleton via CrosLibrary::Get(). | 1599 // For normal usage, access the singleton via CrosLibrary::Get(). |
| 1651 static NetworkLibrary* GetImpl(bool stub); | 1600 static NetworkLibrary* GetImpl(bool stub); |
| 1652 }; | 1601 }; |
| 1653 | 1602 |
| 1654 } // namespace chromeos | 1603 } // namespace chromeos |
| 1655 | 1604 |
| 1656 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ | 1605 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ |
| OLD | NEW |