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

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

Issue 9702005: Call libcros functions through proxy functions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 8 years, 9 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/cros/network_library.h" 5 #include "chrome/browser/chromeos/cros/network_library.h"
6 6
7 #include <dbus/dbus-glib.h> 7 #include <dbus/dbus-glib.h>
8 8
9 #include "base/i18n/icu_encoding_detection.h" 9 #include "base/i18n/icu_encoding_detection.h"
10 #include "base/i18n/icu_string_conversions.h" 10 #include "base/i18n/icu_string_conversions.h"
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 void Network::CopyCredentialsFromRemembered(Network* remembered) { 298 void Network::CopyCredentialsFromRemembered(Network* remembered) {
299 } 299 }
300 300
301 void Network::SetValueProperty(const char* prop, Value* value) { 301 void Network::SetValueProperty(const char* prop, Value* value) {
302 DCHECK(prop); 302 DCHECK(prop);
303 DCHECK(value); 303 DCHECK(value);
304 if (!EnsureCrosLoaded()) 304 if (!EnsureCrosLoaded())
305 return; 305 return;
306 scoped_ptr<GValue> gvalue( 306 scoped_ptr<GValue> gvalue(
307 NetworkLibraryImplCros::ConvertValueToGValue(value)); 307 NetworkLibraryImplCros::ConvertValueToGValue(value));
308 chromeos::SetNetworkServicePropertyGValue( 308 CrosSetNetworkServicePropertyGValue(
309 service_path_.c_str(), prop, gvalue.get()); 309 service_path_.c_str(), prop, gvalue.get());
310 } 310 }
311 311
312 void Network::ClearProperty(const char* prop) { 312 void Network::ClearProperty(const char* prop) {
313 DCHECK(prop); 313 DCHECK(prop);
314 if (!EnsureCrosLoaded()) 314 if (!EnsureCrosLoaded())
315 return; 315 return;
316 chromeos::ClearNetworkServiceProperty(service_path_.c_str(), prop); 316 CrosClearNetworkServiceProperty(service_path_.c_str(), prop);
317 } 317 }
318 318
319 void Network::SetStringProperty( 319 void Network::SetStringProperty(
320 const char* prop, const std::string& str, std::string* dest) { 320 const char* prop, const std::string& str, std::string* dest) {
321 if (dest) 321 if (dest)
322 *dest = str; 322 *dest = str;
323 scoped_ptr<Value> value(Value::CreateStringValue(str)); 323 scoped_ptr<Value> value(Value::CreateStringValue(str));
324 SetValueProperty(prop, value.get()); 324 SetValueProperty(prop, value.get());
325 } 325 }
326 326
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 SetOrClearStringProperty( 479 SetOrClearStringProperty(
480 flimflam::kProxyConfigProperty, proxy_config, &proxy_config_); 480 flimflam::kProxyConfigProperty, proxy_config, &proxy_config_);
481 } 481 }
482 482
483 void Network::InitIPAddress() { 483 void Network::InitIPAddress() {
484 ip_address_.clear(); 484 ip_address_.clear();
485 if (!EnsureCrosLoaded()) 485 if (!EnsureCrosLoaded())
486 return; 486 return;
487 // If connected, get ip config. 487 // If connected, get ip config.
488 if (connected() && !device_path_.empty()) { 488 if (connected() && !device_path_.empty()) {
489 IPConfigStatus* ipconfig_status = 489 IPConfigStatus* ipconfig_status = CrosListIPConfigs(device_path_.c_str());
490 chromeos::ListIPConfigs(device_path_.c_str());
491 if (ipconfig_status) { 490 if (ipconfig_status) {
492 for (int i = 0; i < ipconfig_status->size; ++i) { 491 for (int i = 0; i < ipconfig_status->size; ++i) {
493 IPConfig ipconfig = ipconfig_status->ips[i]; 492 IPConfig ipconfig = ipconfig_status->ips[i];
494 if (strlen(ipconfig.address) > 0) { 493 if (strlen(ipconfig.address) > 0) {
495 ip_address_ = ipconfig.address; 494 ip_address_ = ipconfig.address;
496 break; 495 break;
497 } 496 }
498 } 497 }
499 chromeos::FreeIPConfigStatus(ipconfig_status); 498 CrosFreeIPConfigStatus(ipconfig_status);
500 } 499 }
501 } 500 }
502 } 501 }
503 502
504 bool Network::UpdateStatus(const std::string& key, 503 bool Network::UpdateStatus(const std::string& key,
505 const Value& value, 504 const Value& value,
506 PropertyIndex* index) { 505 PropertyIndex* index) {
507 if (network_parser_.get()) 506 if (network_parser_.get())
508 return network_parser_->UpdateStatus(key, value, this, index); 507 return network_parser_->UpdateStatus(key, value, this, index);
509 return false; 508 return false;
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 using_post_(false), 992 using_post_(false),
994 data_left_(DATA_UNKNOWN) { 993 data_left_(DATA_UNKNOWN) {
995 } 994 }
996 995
997 CellularNetwork::~CellularNetwork() { 996 CellularNetwork::~CellularNetwork() {
998 } 997 }
999 998
1000 bool CellularNetwork::StartActivation() { 999 bool CellularNetwork::StartActivation() {
1001 if (!EnsureCrosLoaded()) 1000 if (!EnsureCrosLoaded())
1002 return false; 1001 return false;
1003 if (!chromeos::ActivateCellularModem(service_path().c_str(), NULL)) 1002 if (!CrosActivateCellularModem(service_path().c_str(), NULL))
1004 return false; 1003 return false;
1005 // Don't wait for flimflam to tell us that we are really activating since 1004 // Don't wait for flimflam to tell us that we are really activating since
1006 // other notifications in the message loop might cause us to think that 1005 // other notifications in the message loop might cause us to think that
1007 // the process hasn't started yet. 1006 // the process hasn't started yet.
1008 activation_state_ = ACTIVATION_STATE_ACTIVATING; 1007 activation_state_ = ACTIVATION_STATE_ACTIVATING;
1009 return true; 1008 return true;
1010 } 1009 }
1011 1010
1012 void CellularNetwork::RefreshDataPlansIfNeeded() const { 1011 void CellularNetwork::RefreshDataPlansIfNeeded() const {
1013 if (!EnsureCrosLoaded()) 1012 if (!EnsureCrosLoaded())
1014 return; 1013 return;
1015 if (connected() && activated()) 1014 if (connected() && activated())
1016 chromeos::RequestCellularDataPlanUpdate(service_path().c_str()); 1015 CrosRequestCellularDataPlanUpdate(service_path().c_str());
1017 } 1016 }
1018 1017
1019 void CellularNetwork::SetApn(const CellularApn& apn) { 1018 void CellularNetwork::SetApn(const CellularApn& apn) {
1020 if (!apn.apn.empty()) { 1019 if (!apn.apn.empty()) {
1021 DictionaryValue value; 1020 DictionaryValue value;
1022 // Only use the fields that are needed for establishing 1021 // Only use the fields that are needed for establishing
1023 // connections, and ignore the rest. 1022 // connections, and ignore the rest.
1024 value.SetString(flimflam::kApnProperty, apn.apn); 1023 value.SetString(flimflam::kApnProperty, apn.apn);
1025 value.SetString(flimflam::kApnNetworkIdProperty, apn.network_id); 1024 value.SetString(flimflam::kApnNetworkIdProperty, apn.network_id);
1026 value.SetString(flimflam::kApnUsernameProperty, apn.username); 1025 value.SetString(flimflam::kApnUsernameProperty, apn.username);
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1437 NetworkLibrary* impl; 1436 NetworkLibrary* impl;
1438 if (stub) 1437 if (stub)
1439 impl = new NetworkLibraryImplStub(); 1438 impl = new NetworkLibraryImplStub();
1440 else 1439 else
1441 impl = new NetworkLibraryImplCros(); 1440 impl = new NetworkLibraryImplCros();
1442 impl->Init(); 1441 impl->Init();
1443 return impl; 1442 return impl;
1444 } 1443 }
1445 1444
1446 } // namespace chromeos 1445 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698