| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/shell/browser/layout_test/layout_test_bluetooth_chooser_factor
y.h" | 5 #include "content/shell/browser/layout_test/layout_test_bluetooth_chooser_factor
y.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "content/public/browser/render_frame_host.h" | 10 #include "content/public/browser/render_frame_host.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 bool is_paired, | 68 bool is_paired, |
| 69 int signal_strength_level) override { | 69 int signal_strength_level) override { |
| 70 CheckFactory(); | 70 CheckFactory(); |
| 71 std::string event = "add-device("; | 71 std::string event = "add-device("; |
| 72 event += base::UTF16ToUTF8(device_name); | 72 event += base::UTF16ToUTF8(device_name); |
| 73 event += ")="; | 73 event += ")="; |
| 74 event += device_id; | 74 event += device_id; |
| 75 factory_->events_.push_back(event); | 75 factory_->events_.push_back(event); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void RemoveDevice(const std::string& device_id) override { | |
| 79 CheckFactory(); | |
| 80 std::string event = "remove-device("; | |
| 81 event += device_id; | |
| 82 event += ")"; | |
| 83 factory_->events_.push_back(event); | |
| 84 } | |
| 85 | |
| 86 EventHandler event_handler; | 78 EventHandler event_handler; |
| 87 | 79 |
| 88 private: | 80 private: |
| 89 void CheckFactory() const { | 81 void CheckFactory() const { |
| 90 CHECK(factory_) << "The factory should cancel all choosers in its " | 82 CHECK(factory_) << "The factory should cancel all choosers in its " |
| 91 "destructor, and choosers should be destroyed " | 83 "destructor, and choosers should be destroyed " |
| 92 "synchronously when canceled."; | 84 "synchronously when canceled."; |
| 93 } | 85 } |
| 94 | 86 |
| 95 base::WeakPtr<LayoutTestBluetoothChooserFactory> factory_; | 87 base::WeakPtr<LayoutTestBluetoothChooserFactory> factory_; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 const std::string& device_id) { | 121 const std::string& device_id) { |
| 130 // Copy |choosers_| to make sure event handler executions that modify | 122 // Copy |choosers_| to make sure event handler executions that modify |
| 131 // |choosers_| don't invalidate iterators. | 123 // |choosers_| don't invalidate iterators. |
| 132 std::vector<Chooser*> choosers_copy(choosers_.begin(), choosers_.end()); | 124 std::vector<Chooser*> choosers_copy(choosers_.begin(), choosers_.end()); |
| 133 for (Chooser* chooser : choosers_copy) { | 125 for (Chooser* chooser : choosers_copy) { |
| 134 chooser->event_handler.Run(event, device_id); | 126 chooser->event_handler.Run(event, device_id); |
| 135 } | 127 } |
| 136 } | 128 } |
| 137 | 129 |
| 138 } // namespace content | 130 } // namespace content |
| OLD | NEW |