| 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_function.h" | 5 #include "chrome/browser/extensions/api/api_function.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "chrome/browser/extensions/api/api_resource_event_notifier.h" | 8 #include "chrome/browser/extensions/api/api_resource_event_notifier.h" |
| 9 #include "chrome/browser/extensions/extension_system.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 10 | 11 |
| 11 using content::BrowserThread; | 12 using content::BrowserThread; |
| 12 | 13 |
| 13 namespace extensions { | 14 namespace extensions { |
| 14 | 15 |
| 15 ApiFunction::ApiFunction() { | 16 ApiFunction::ApiFunction() { |
| 16 } | 17 } |
| 17 | 18 |
| 18 ApiFunction::~ApiFunction() { | 19 ApiFunction::~ApiFunction() { |
| 19 } | 20 } |
| 20 | 21 |
| 21 int ApiFunction::ExtractSrcId(const DictionaryValue* options) { | 22 int ApiFunction::ExtractSrcId(const DictionaryValue* options) { |
| 22 int src_id = -1; | 23 int src_id = -1; |
| 23 if (options) { | 24 if (options) { |
| 24 if (options->HasKey(kSrcIdKey)) | 25 if (options->HasKey(kSrcIdKey)) |
| 25 EXTENSION_FUNCTION_VALIDATE(options->GetInteger(kSrcIdKey, &src_id)); | 26 EXTENSION_FUNCTION_VALIDATE(options->GetInteger(kSrcIdKey, &src_id)); |
| 26 } | 27 } |
| 27 return src_id; | 28 return src_id; |
| 28 } | 29 } |
| 29 | 30 |
| 30 ApiResourceEventNotifier* ApiFunction::CreateEventNotifier(int src_id) { | 31 ApiResourceEventNotifier* ApiFunction::CreateEventNotifier(int src_id) { |
| 31 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 32 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 32 return new ApiResourceEventNotifier( | 33 return new ApiResourceEventNotifier( |
| 33 profile()->GetExtensionEventRouter(), profile(), extension_id(), | 34 extensions::ExtensionSystem::Get(profile())->event_router(), profile(), |
| 34 src_id, source_url()); | 35 extension_id(), src_id, source_url()); |
| 35 } | 36 } |
| 36 | 37 |
| 37 // AsyncApiFunction | 38 // AsyncApiFunction |
| 38 AsyncApiFunction::AsyncApiFunction() | 39 AsyncApiFunction::AsyncApiFunction() |
| 39 : work_thread_id_(BrowserThread::IO) { | 40 : work_thread_id_(BrowserThread::IO) { |
| 40 } | 41 } |
| 41 | 42 |
| 42 AsyncApiFunction::~AsyncApiFunction() { | 43 AsyncApiFunction::~AsyncApiFunction() { |
| 43 } | 44 } |
| 44 | 45 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 "specify a different thread or derive from a different class."; | 87 "specify a different thread or derive from a different class."; |
| 87 AsyncWorkStart(); | 88 AsyncWorkStart(); |
| 88 } | 89 } |
| 89 | 90 |
| 90 void AsyncApiFunction::RespondOnUIThread() { | 91 void AsyncApiFunction::RespondOnUIThread() { |
| 91 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 92 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 92 SendResponse(Respond()); | 93 SendResponse(Respond()); |
| 93 } | 94 } |
| 94 | 95 |
| 95 } // namespace extensions | 96 } // namespace extensions |
| OLD | NEW |