OLD | NEW |
---|---|
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/extensions/api/api_resource_event_notifier.h" | 5 #include "chrome/browser/extensions/api/api_resource_event_notifier.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/extensions/extension_event_router.h" | 10 #include "chrome/browser/extensions/extension_event_router.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 BrowserThread::UI, FROM_HERE, | 127 BrowserThread::UI, FROM_HERE, |
128 base::Bind( | 128 base::Bind( |
129 &APIResourceEventNotifier::DispatchEventOnUIThread, this, extension, | 129 &APIResourceEventNotifier::DispatchEventOnUIThread, this, extension, |
130 event)); | 130 event)); |
131 } | 131 } |
132 | 132 |
133 void APIResourceEventNotifier::DispatchEventOnUIThread( | 133 void APIResourceEventNotifier::DispatchEventOnUIThread( |
134 const std::string &extension, DictionaryValue* event) { | 134 const std::string &extension, DictionaryValue* event) { |
135 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 135 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
136 | 136 |
137 ListValue args; | 137 ListValue* const arguments = new ListValue(); |
miket_OOO
2012/07/10 22:33:19
For future grep/sed/readability sanity, can you ch
| |
138 args.Set(0, event); | 138 arguments->Set(0, event); |
139 router_->DispatchEventToExtension(src_extension_id_, extension, args, | 139 router_->DispatchEventToExtension(src_extension_id_, extension, arguments, |
140 profile_, src_url_); | 140 profile_, src_url_); |
141 } | 141 } |
142 | 142 |
143 DictionaryValue* APIResourceEventNotifier::CreateAPIResourceEvent( | 143 DictionaryValue* APIResourceEventNotifier::CreateAPIResourceEvent( |
144 APIResourceEventType event_type) { | 144 APIResourceEventType event_type) { |
145 DictionaryValue* event = new DictionaryValue(); | 145 DictionaryValue* event = new DictionaryValue(); |
146 event->SetString(kEventTypeKey, APIResourceEventTypeToString(event_type)); | 146 event->SetString(kEventTypeKey, APIResourceEventTypeToString(event_type)); |
147 event->SetInteger(kSrcIdKey, src_id_); | 147 event->SetInteger(kSrcIdKey, src_id_); |
148 | 148 |
149 // TODO(miket): Signal that it's OK to clean up onEvent listeners. This is | 149 // TODO(miket): Signal that it's OK to clean up onEvent listeners. This is |
(...skipping 11 matching lines...) Expand all Loading... | |
161 int result_code) { | 161 int result_code) { |
162 if (src_id_ < 0) | 162 if (src_id_ < 0) |
163 return; | 163 return; |
164 | 164 |
165 DictionaryValue* event = CreateAPIResourceEvent(event_type); | 165 DictionaryValue* event = CreateAPIResourceEvent(event_type); |
166 event->SetInteger(kResultCodeKey, result_code); | 166 event->SetInteger(kResultCodeKey, result_code); |
167 DispatchEvent(extension, event); | 167 DispatchEvent(extension, event); |
168 } | 168 } |
169 | 169 |
170 } // namespace extensions | 170 } // namespace extensions |
OLD | NEW |