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

Side by Side Diff: chrome/browser/chromeos/cros/network_library.cc

Issue 6347044: Only show notification for low 3g data for the last data-based plan.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/cros/network_library.h" 5 #include "chrome/browser/chromeos/cros/network_library.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "base/i18n/time_formatting.h" 10 #include "base/i18n/time_formatting.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 const std::string& roaming_state) { 160 const std::string& roaming_state) {
161 if (roaming_state == kRoamingStateHome) 161 if (roaming_state == kRoamingStateHome)
162 return ROAMING_STATE_HOME; 162 return ROAMING_STATE_HOME;
163 if (roaming_state == kRoamingStateRoaming) 163 if (roaming_state == kRoamingStateRoaming)
164 return ROAMING_STATE_ROAMING; 164 return ROAMING_STATE_ROAMING;
165 if (roaming_state == kRoamingStateUnknown) 165 if (roaming_state == kRoamingStateUnknown)
166 return ROAMING_STATE_UNKNOWN; 166 return ROAMING_STATE_UNKNOWN;
167 return ROAMING_STATE_UNKNOWN; 167 return ROAMING_STATE_UNKNOWN;
168 } 168 }
169 169
170 } 170 } // namespace
171 171
172 // Helper function to wrap Html with <th> tag. 172 // Helper function to wrap Html with <th> tag.
173 static std::string WrapWithTH(std::string text) { 173 static std::string WrapWithTH(std::string text) {
174 return "<th>" + text + "</th>"; 174 return "<th>" + text + "</th>";
175 } 175 }
176 176
177 // Helper function to wrap Html with <td> tag. 177 // Helper function to wrap Html with <td> tag.
178 static std::string WrapWithTD(std::string text) { 178 static std::string WrapWithTD(std::string text) {
179 return "<td>" + text + "</td>"; 179 return "<td>" + text + "</td>";
180 } 180 }
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 } else if (plan_type == chromeos::CELLULAR_DATA_PLAN_METERED_PAID || 464 } else if (plan_type == chromeos::CELLULAR_DATA_PLAN_METERED_PAID ||
465 plan_type == chromeos::CELLULAR_DATA_PLAN_METERED_BASE) { 465 plan_type == chromeos::CELLULAR_DATA_PLAN_METERED_BASE) {
466 // Metered plan. Show low data and out of data. 466 // Metered plan. Show low data and out of data.
467 return l10n_util::GetStringFUTF16( 467 return l10n_util::GetStringFUTF16(
468 IDS_NETWORK_DATA_AVAILABLE_MESSAGE, 468 IDS_NETWORK_DATA_AVAILABLE_MESSAGE,
469 UTF8ToUTF16(base::Int64ToString(remaining_mbytes()))); 469 UTF8ToUTF16(base::Int64ToString(remaining_mbytes())));
470 } 470 }
471 return string16(); 471 return string16();
472 } 472 }
473 473
474 std::string CellularDataPlan::GetUniqueIdentifier() const {
475 // A cellular plan is uniquely described by the union of name, type,
476 // start time, end time, and max bytes.
477 // So we just return a union of all these variables.
478 return plan_name + "|" +
479 base::Int64ToString(plan_type) + "|" +
480 base::Int64ToString(plan_start_time.ToInternalValue()) + "|" +
481 base::Int64ToString(plan_end_time.ToInternalValue()) + "|" +
482 base::Int64ToString(plan_data_bytes);
483 }
484
474 base::TimeDelta CellularDataPlan::remaining_time() const { 485 base::TimeDelta CellularDataPlan::remaining_time() const {
475 base::TimeDelta time = plan_end_time - base::Time::Now(); 486 base::TimeDelta time = plan_end_time - base::Time::Now();
476 return time.InMicroseconds() < 0 ? base::TimeDelta() : time; 487 return time.InMicroseconds() < 0 ? base::TimeDelta() : time;
477 } 488 }
478 489
479 int64 CellularDataPlan::remaining_minutes() const { 490 int64 CellularDataPlan::remaining_minutes() const {
480 return remaining_time().InMinutes(); 491 return remaining_time().InMinutes();
481 } 492 }
482 493
483 int64 CellularDataPlan::remaining_data() const { 494 int64 CellularDataPlan::remaining_data() const {
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 ++map_iter; 954 ++map_iter;
944 } 955 }
945 } 956 }
946 } 957 }
947 958
948 virtual void Lock() { 959 virtual void Lock() {
949 if (is_locked_) 960 if (is_locked_)
950 return; 961 return;
951 is_locked_ = true; 962 is_locked_ = true;
952 NotifyNetworkManagerChanged(); 963 NotifyNetworkManagerChanged();
953 } 964 }
954 965
955 virtual void Unlock() { 966 virtual void Unlock() {
956 DCHECK(is_locked_); 967 DCHECK(is_locked_);
957 if (!is_locked_) 968 if (!is_locked_)
958 return; 969 return;
959 is_locked_ = false; 970 is_locked_ = false;
960 NotifyNetworkManagerChanged(); 971 NotifyNetworkManagerChanged();
961 } 972 }
962 973
963 virtual bool IsLocked() { 974 virtual bool IsLocked() {
(...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after
2081 return new NetworkLibraryStubImpl(); 2092 return new NetworkLibraryStubImpl();
2082 else 2093 else
2083 return new NetworkLibraryImpl(); 2094 return new NetworkLibraryImpl();
2084 } 2095 }
2085 2096
2086 } // namespace chromeos 2097 } // namespace chromeos
2087 2098
2088 // Allows InvokeLater without adding refcounting. This class is a Singleton and 2099 // Allows InvokeLater without adding refcounting. This class is a Singleton and
2089 // won't be deleted until it's last InvokeLater is run. 2100 // won't be deleted until it's last InvokeLater is run.
2090 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::NetworkLibraryImpl); 2101 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::NetworkLibraryImpl);
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/cros/network_library.h ('k') | chrome/browser/chromeos/network_message_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698