| 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 "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_
connection_manager.h" | 5 #include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_
connection_manager.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 api::easy_unlock_private::OnSendCompleted::Create(0, data, success); | 146 api::easy_unlock_private::OnSendCompleted::Create(0, data, success); |
| 147 DispatchConnectionEvent(event_name, histogram_value, &connection, | 147 DispatchConnectionEvent(event_name, histogram_value, &connection, |
| 148 std::move(args)); | 148 std::move(args)); |
| 149 } | 149 } |
| 150 | 150 |
| 151 void EasyUnlockPrivateConnectionManager::DispatchConnectionEvent( | 151 void EasyUnlockPrivateConnectionManager::DispatchConnectionEvent( |
| 152 const std::string& event_name, | 152 const std::string& event_name, |
| 153 events::HistogramValue histogram_value, | 153 events::HistogramValue histogram_value, |
| 154 const Connection* connection, | 154 const Connection* connection, |
| 155 std::unique_ptr<base::ListValue> args) { | 155 std::unique_ptr<base::ListValue> args) { |
| 156 const EventListenerMap::ListenerList listeners = | 156 const EventListenerMap::ListenerList& listeners = |
| 157 EventRouter::Get(browser_context_) | 157 EventRouter::Get(browser_context_) |
| 158 ->listeners() | 158 ->listeners() |
| 159 .GetEventListenersByName(event_name); | 159 .GetEventListenersByName(event_name); |
| 160 for (const auto& listener : listeners) { | 160 for (const auto& listener : listeners) { |
| 161 std::string extension_id = listener->extension_id(); | 161 std::string extension_id = listener->extension_id(); |
| 162 int connection_id = FindConnectionId(extension_id, connection); | 162 int connection_id = FindConnectionId(extension_id, connection); |
| 163 std::unique_ptr<base::ListValue> args_copy(args->DeepCopy()); | 163 std::unique_ptr<base::ListValue> args_copy(args->DeepCopy()); |
| 164 int connection_index = 0; | 164 int connection_index = 0; |
| 165 args_copy->Set(connection_index, | 165 args_copy->Set(connection_index, |
| 166 base::WrapUnique(new base::FundamentalValue(connection_id))); | 166 base::WrapUnique(new base::FundamentalValue(connection_id))); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 195 base::hash_set<int>* connection_ids = | 195 base::hash_set<int>* connection_ids = |
| 196 GetResourceManager()->GetResourceIds(extension_id); | 196 GetResourceManager()->GetResourceIds(extension_id); |
| 197 for (int connection_id : *connection_ids) { | 197 for (int connection_id : *connection_ids) { |
| 198 if (connection == GetConnection(extension_id, connection_id)) | 198 if (connection == GetConnection(extension_id, connection_id)) |
| 199 return connection_id; | 199 return connection_id; |
| 200 } | 200 } |
| 201 return 0; | 201 return 0; |
| 202 } | 202 } |
| 203 | 203 |
| 204 } // namespace extensions | 204 } // namespace extensions |
| OLD | NEW |