OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/pairing/fake_controller_pairing_controller.h" | 5 #include "components/pairing/fake_controller_pairing_controller.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 | 75 |
76 if (!dict.count("discovery")) { | 76 if (!dict.count("discovery")) { |
77 dict["discovery"] = | 77 dict["discovery"] = |
78 "F-Device_1~F-Device_5~F-Device_3~L-Device_3~L-Device_1~F-Device_1"; | 78 "F-Device_1~F-Device_5~F-Device_3~L-Device_3~L-Device_1~F-Device_1"; |
79 } | 79 } |
80 base::StringPairs events; | 80 base::StringPairs events; |
81 CHECK( | 81 CHECK( |
82 base::SplitStringIntoKeyValuePairs(dict["discovery"], '-', '~', &events)) | 82 base::SplitStringIntoKeyValuePairs(dict["discovery"], '-', '~', &events)) |
83 << "Wrong 'discovery' format."; | 83 << "Wrong 'discovery' format."; |
84 DiscoveryScenario scenario; | 84 DiscoveryScenario scenario; |
85 for (base::StringPairs::const_iterator event = events.begin(); | 85 for (const auto& event : events) { |
86 event != events.end(); | 86 std::string type = event.first; |
achuithb
2014/10/02 21:09:54
let's avoid the copy and make these const std::str
Zachary Kuznia
2014/10/02 21:25:16
Done.
| |
87 ++event) { | 87 std::string device_id = event.second; |
88 std::string type = event->first; | |
89 std::string device_id = event->second; | |
90 CHECK(type == "F" || type == "L" || type == "N") | 88 CHECK(type == "F" || type == "L" || type == "N") |
91 << "Wrong discovery event type."; | 89 << "Wrong discovery event type."; |
92 CHECK(!device_id.empty() || type == "N") << "Empty device ID."; | 90 CHECK(!device_id.empty() || type == "N") << "Empty device ID."; |
93 scenario.push_back(DiscoveryEvent( | 91 scenario.push_back(DiscoveryEvent( |
94 type == "F" ? DEVICE_FOUND : type == "L" ? DEVICE_LOST : NOTHING_FOUND, | 92 type == "F" ? DEVICE_FOUND : type == "L" ? DEVICE_LOST : NOTHING_FOUND, |
95 device_id)); | 93 device_id)); |
96 } | 94 } |
97 SetDiscoveryScenario(scenario); | 95 SetDiscoveryScenario(scenario); |
98 | 96 |
99 preset_confirmation_code_ = dict["code"]; | 97 preset_confirmation_code_ = dict["code"]; |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
334 next_stage = STAGE_HOST_CONNECTION_LOST; | 332 next_stage = STAGE_HOST_CONNECTION_LOST; |
335 } | 333 } |
336 if (next_stage != STAGE_NONE) | 334 if (next_stage != STAGE_NONE) |
337 ChangeStageLater(next_stage); | 335 ChangeStageLater(next_stage); |
338 } | 336 } |
339 | 337 |
340 void FakeControllerPairingController::DiscoveredDevicesListChanged() { | 338 void FakeControllerPairingController::DiscoveredDevicesListChanged() { |
341 } | 339 } |
342 | 340 |
343 } // namespace pairing_chromeos | 341 } // namespace pairing_chromeos |
OLD | NEW |