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

Side by Side Diff: chrome/browser/chromeos/mobile/mobile_activator.cc

Issue 23441025: Clean up NetworkState members (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address feedback Created 7 years, 3 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) 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 "chrome/browser/chromeos/mobile/mobile_activator.h" 5 #include "chrome/browser/chromeos/mobile/mobile_activator.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 MobileActivator::MobileActivator() 158 MobileActivator::MobileActivator()
159 : cellular_config_(new CellularConfigDocument()), 159 : cellular_config_(new CellularConfigDocument()),
160 state_(PLAN_ACTIVATION_PAGE_LOADING), 160 state_(PLAN_ACTIVATION_PAGE_LOADING),
161 reenable_cert_check_(false), 161 reenable_cert_check_(false),
162 terminated_(true), 162 terminated_(true),
163 pending_activation_request_(false), 163 pending_activation_request_(false),
164 connection_retry_count_(0), 164 connection_retry_count_(0),
165 initial_OTASP_attempts_(0), 165 initial_OTASP_attempts_(0),
166 trying_OTASP_attempts_(0), 166 trying_OTASP_attempts_(0),
167 final_OTASP_attempts_(0), 167 final_OTASP_attempts_(0),
168 payment_reconnect_count_(0) { 168 payment_reconnect_count_(0),
169 weak_ptr_factory_(this) {
169 } 170 }
170 171
171 MobileActivator::~MobileActivator() { 172 MobileActivator::~MobileActivator() {
172 TerminateActivation(); 173 TerminateActivation();
173 } 174 }
174 175
175 MobileActivator* MobileActivator::GetInstance() { 176 MobileActivator* MobileActivator::GetInstance() {
176 return Singleton<MobileActivator>::get(); 177 return Singleton<MobileActivator>::get();
177 } 178 }
178 179
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 262
262 ChangeState(network, PLAN_ACTIVATION_PAGE_LOADING, ""); 263 ChangeState(network, PLAN_ACTIVATION_PAGE_LOADING, "");
263 264
264 BrowserThread::PostTaskAndReply(BrowserThread::FILE, FROM_HERE, 265 BrowserThread::PostTaskAndReply(BrowserThread::FILE, FROM_HERE,
265 base::Bind(&CellularConfigDocument::LoadCellularConfigFile, 266 base::Bind(&CellularConfigDocument::LoadCellularConfigFile,
266 cellular_config_.get()), 267 cellular_config_.get()),
267 base::Bind(&MobileActivator::ContinueActivation, AsWeakPtr())); 268 base::Bind(&MobileActivator::ContinueActivation, AsWeakPtr()));
268 } 269 }
269 270
270 void MobileActivator::ContinueActivation() { 271 void MobileActivator::ContinueActivation() {
271 const NetworkState* network = GetNetworkState(service_path_); 272 NetworkHandler::Get()->network_configuration_handler()->GetProperties(
272 if (!network || 273 service_path_,
273 (network->payment_url().empty() && network->usage_url().empty())) 274 base::Bind(&MobileActivator::GetPropertiesAndContinueActivation,
275 weak_ptr_factory_.GetWeakPtr()),
276 base::Bind(&MobileActivator::GetPropertiesFailure,
277 weak_ptr_factory_.GetWeakPtr()));
278 }
279
280 void MobileActivator::GetPropertiesAndContinueActivation(
281 const std::string& service_path,
282 const base::DictionaryValue& properties) {
283 if (service_path != service_path_)
284 return; // Edge case; abort.
armansito 2013/09/04 01:35:31 nit: Please add a log message here.
stevenjb 2013/09/04 18:47:52 Done.
285
286 const DictionaryValue* payment_dict;
287 std::string usage_url, payment_url;
288 if (!properties.GetStringWithoutPathExpansion(
289 flimflam::kUsageURLProperty, &usage_url) ||
290 !properties.GetDictionaryWithoutPathExpansion(
291 flimflam::kPaymentPortalProperty, &payment_dict) ||
292 !payment_dict->GetStringWithoutPathExpansion(
293 flimflam::kPaymentPortalURL, &payment_url)) {
294 NET_LOG_ERROR("MobileActivator missing properties", service_path_);
295 return;
296 }
297
298 if (payment_url.empty() && usage_url.empty())
274 return; 299 return;
275 300
276 DisableCertRevocationChecking(); 301 DisableCertRevocationChecking();
277 302
278 // We want shill to connect us after activations, so enable autoconnect. 303 // We want shill to connect us after activations, so enable autoconnect.
279 DictionaryValue auto_connect_property; 304 DictionaryValue auto_connect_property;
280 auto_connect_property.SetBoolean(flimflam::kAutoConnectProperty, true); 305 auto_connect_property.SetBoolean(flimflam::kAutoConnectProperty, true);
281 NetworkHandler::Get()->network_configuration_handler()->SetProperties( 306 NetworkHandler::Get()->network_configuration_handler()->SetProperties(
282 network->path(), 307 service_path_,
283 auto_connect_property, 308 auto_connect_property,
284 base::Bind(&base::DoNothing), 309 base::Bind(&base::DoNothing),
285 network_handler::ErrorCallback()); 310 network_handler::ErrorCallback());
286 StartActivation(); 311 StartActivation();
287 } 312 }
288 313
314 void MobileActivator::GetPropertiesFailure(
315 const std::string& error_name,
316 scoped_ptr<base::DictionaryValue> error_data) {
317 NET_LOG_ERROR("MobileActivator GetProperties Failed: " + error_name,
318 service_path_);
319 }
320
289 void MobileActivator::OnSetTransactionStatus(bool success) { 321 void MobileActivator::OnSetTransactionStatus(bool success) {
290 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 322 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
291 base::Bind(&MobileActivator::HandleSetTransactionStatus, 323 base::Bind(&MobileActivator::HandleSetTransactionStatus,
292 AsWeakPtr(), success)); 324 AsWeakPtr(), success));
293 } 325 }
294 326
295 void MobileActivator::HandleSetTransactionStatus(bool success) { 327 void MobileActivator::HandleSetTransactionStatus(bool success) {
296 // The payment is received, try to reconnect and check the status all over 328 // The payment is received, try to reconnect and check the status all over
297 // again. 329 // again.
298 if (success && state_ == PLAN_ACTIVATION_SHOWING_PAYMENT) { 330 if (success && state_ == PLAN_ACTIVATION_SHOWING_PAYMENT) {
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 cellular_plan_payment_time_ = base::Time::Now(); 1051 cellular_plan_payment_time_ = base::Time::Now();
1020 } 1052 }
1021 1053
1022 bool MobileActivator::HasRecentCellularPlanPayment() const { 1054 bool MobileActivator::HasRecentCellularPlanPayment() const {
1023 const int kRecentPlanPaymentHours = 6; 1055 const int kRecentPlanPaymentHours = 6;
1024 return (base::Time::Now() - 1056 return (base::Time::Now() -
1025 cellular_plan_payment_time_).InHours() < kRecentPlanPaymentHours; 1057 cellular_plan_payment_time_).InHours() < kRecentPlanPaymentHours;
1026 } 1058 }
1027 1059
1028 } // namespace chromeos 1060 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698