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

Side by Side Diff: chromeos/network/network_state_handler.cc

Issue 1562593002: Fix potential crashes in NetworkHandler code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@test
Patch Set: Created 4 years, 11 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
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 "chromeos/network/network_state_handler.h" 5 #include "chromeos/network/network_state_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/format_macros.h" 10 #include "base/format_macros.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 NetworkStateHandler* NetworkStateHandler::InitializeForTest() { 85 NetworkStateHandler* NetworkStateHandler::InitializeForTest() {
86 NetworkStateHandler* handler = new NetworkStateHandler(); 86 NetworkStateHandler* handler = new NetworkStateHandler();
87 handler->InitShillPropertyHandler(); 87 handler->InitShillPropertyHandler();
88 return handler; 88 return handler;
89 } 89 }
90 90
91 void NetworkStateHandler::AddObserver( 91 void NetworkStateHandler::AddObserver(
92 NetworkStateHandlerObserver* observer, 92 NetworkStateHandlerObserver* observer,
93 const tracked_objects::Location& from_here) { 93 const tracked_objects::Location& from_here) {
94 observers_.AddObserver(observer); 94 observers_.AddObserver(observer);
95 device_event_log::AddEntry(from_here.file_name(), from_here.line_number(), 95 device_event_log::AddEntry(
96 device_event_log::LOG_TYPE_NETWORK, 96 from_here.file_name(), from_here.line_number(),
97 device_event_log::LOG_LEVEL_DEBUG, 97 device_event_log::LOG_TYPE_NETWORK, device_event_log::LOG_LEVEL_DEBUG,
98 "NetworkStateHandler::AddObserver"); 98 base::StringPrintf("NetworkStateHandler::AddObserver: 0x%lx",
99 (int64_t)observer));
oshima 2016/01/05 23:14:36 %p ? (or static_cast<>)
stevenjb 2016/01/06 00:43:04 Done.
99 } 100 }
100 101
101 void NetworkStateHandler::RemoveObserver( 102 void NetworkStateHandler::RemoveObserver(
102 NetworkStateHandlerObserver* observer, 103 NetworkStateHandlerObserver* observer,
103 const tracked_objects::Location& from_here) { 104 const tracked_objects::Location& from_here) {
104 observers_.RemoveObserver(observer); 105 observers_.RemoveObserver(observer);
105 device_event_log::AddEntry(from_here.file_name(), from_here.line_number(), 106 device_event_log::AddEntry(
106 device_event_log::LOG_TYPE_NETWORK, 107 from_here.file_name(), from_here.line_number(),
107 device_event_log::LOG_LEVEL_DEBUG, 108 device_event_log::LOG_TYPE_NETWORK, device_event_log::LOG_LEVEL_DEBUG,
108 "NetworkStateHandler::RemoveObserver"); 109 base::StringPrintf("NetworkStateHandler::RemoveObserver: 0x%lx",
110 (int64_t)observer));
oshima 2016/01/05 23:14:36 ditto
stevenjb 2016/01/06 00:43:04 Done.
109 } 111 }
110 112
111 NetworkStateHandler::TechnologyState NetworkStateHandler::GetTechnologyState( 113 NetworkStateHandler::TechnologyState NetworkStateHandler::GetTechnologyState(
112 const NetworkTypePattern& type) const { 114 const NetworkTypePattern& type) const {
113 std::string technology = GetTechnologyForType(type); 115 std::string technology = GetTechnologyForType(type);
114 TechnologyState state; 116 TechnologyState state;
115 if (shill_property_handler_->IsTechnologyEnabled(technology)) 117 if (shill_property_handler_->IsTechnologyEnabled(technology))
116 state = TECHNOLOGY_ENABLED; 118 state = TECHNOLOGY_ENABLED;
117 else if (shill_property_handler_->IsTechnologyEnabling(technology)) 119 else if (shill_property_handler_->IsTechnologyEnabling(technology))
118 state = TECHNOLOGY_ENABLING; 120 state = TECHNOLOGY_ENABLING;
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 if (type.MatchesType(shill::kTypeBluetooth)) 998 if (type.MatchesType(shill::kTypeBluetooth))
997 technologies.push_back(new std::string(shill::kTypeBluetooth)); 999 technologies.push_back(new std::string(shill::kTypeBluetooth));
998 if (type.MatchesType(shill::kTypeVPN)) 1000 if (type.MatchesType(shill::kTypeVPN))
999 technologies.push_back(new std::string(shill::kTypeVPN)); 1001 technologies.push_back(new std::string(shill::kTypeVPN));
1000 1002
1001 CHECK_GT(technologies.size(), 0ul); 1003 CHECK_GT(technologies.size(), 0ul);
1002 return technologies; 1004 return technologies;
1003 } 1005 }
1004 1006
1005 } // namespace chromeos 1007 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698