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

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: Rebase 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 NET_LOG_EVENT("MobileActivator::GetProperties received for stale network",
285 service_path);
286 return; // Edge case; abort.
287 }
288 const DictionaryValue* payment_dict;
289 std::string usage_url, payment_url;
290 if (!properties.GetStringWithoutPathExpansion(
291 flimflam::kUsageURLProperty, &usage_url) ||
292 !properties.GetDictionaryWithoutPathExpansion(
293 flimflam::kPaymentPortalProperty, &payment_dict) ||
294 !payment_dict->GetStringWithoutPathExpansion(
295 flimflam::kPaymentPortalURL, &payment_url)) {
296 NET_LOG_ERROR("MobileActivator missing properties", service_path_);
297 return;
298 }
299
300 if (payment_url.empty() && usage_url.empty())
274 return; 301 return;
275 302
276 DisableCertRevocationChecking(); 303 DisableCertRevocationChecking();
277 304
278 // We want shill to connect us after activations, so enable autoconnect. 305 // We want shill to connect us after activations, so enable autoconnect.
279 DictionaryValue auto_connect_property; 306 DictionaryValue auto_connect_property;
280 auto_connect_property.SetBoolean(flimflam::kAutoConnectProperty, true); 307 auto_connect_property.SetBoolean(flimflam::kAutoConnectProperty, true);
281 NetworkHandler::Get()->network_configuration_handler()->SetProperties( 308 NetworkHandler::Get()->network_configuration_handler()->SetProperties(
282 network->path(), 309 service_path_,
283 auto_connect_property, 310 auto_connect_property,
284 base::Bind(&base::DoNothing), 311 base::Bind(&base::DoNothing),
285 network_handler::ErrorCallback()); 312 network_handler::ErrorCallback());
286 StartActivation(); 313 StartActivation();
287 } 314 }
288 315
316 void MobileActivator::GetPropertiesFailure(
317 const std::string& error_name,
318 scoped_ptr<base::DictionaryValue> error_data) {
319 NET_LOG_ERROR("MobileActivator GetProperties Failed: " + error_name,
320 service_path_);
321 }
322
289 void MobileActivator::OnSetTransactionStatus(bool success) { 323 void MobileActivator::OnSetTransactionStatus(bool success) {
290 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 324 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
291 base::Bind(&MobileActivator::HandleSetTransactionStatus, 325 base::Bind(&MobileActivator::HandleSetTransactionStatus,
292 AsWeakPtr(), success)); 326 AsWeakPtr(), success));
293 } 327 }
294 328
295 void MobileActivator::HandleSetTransactionStatus(bool success) { 329 void MobileActivator::HandleSetTransactionStatus(bool success) {
296 // The payment is received, try to reconnect and check the status all over 330 // The payment is received, try to reconnect and check the status all over
297 // again. 331 // again.
298 if (success && state_ == PLAN_ACTIVATION_SHOWING_PAYMENT) { 332 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(); 1053 cellular_plan_payment_time_ = base::Time::Now();
1020 } 1054 }
1021 1055
1022 bool MobileActivator::HasRecentCellularPlanPayment() const { 1056 bool MobileActivator::HasRecentCellularPlanPayment() const {
1023 const int kRecentPlanPaymentHours = 6; 1057 const int kRecentPlanPaymentHours = 6;
1024 return (base::Time::Now() - 1058 return (base::Time::Now() -
1025 cellular_plan_payment_time_).InHours() < kRecentPlanPaymentHours; 1059 cellular_plan_payment_time_).InHours() < kRecentPlanPaymentHours;
1026 } 1060 }
1027 1061
1028 } // namespace chromeos 1062 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698