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_controller.h" | 8 #include "chrome/browser/extensions/api/api_resource_controller.h" |
9 #include "chrome/browser/extensions/api/api_resource_event_notifier.h" | 9 #include "chrome/browser/extensions/api/api_resource_event_notifier.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 29 matching lines...) Expand all Loading... | |
40 | 40 |
41 void AsyncIOAPIFunction::RespondOnUIThread() { | 41 void AsyncIOAPIFunction::RespondOnUIThread() { |
42 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 42 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
43 SendResponse(Respond()); | 43 SendResponse(Respond()); |
44 } | 44 } |
45 | 45 |
46 int AsyncIOAPIFunction::ExtractSrcId(size_t argument_position) { | 46 int AsyncIOAPIFunction::ExtractSrcId(size_t argument_position) { |
47 scoped_ptr<DictionaryValue> options(new DictionaryValue()); | 47 scoped_ptr<DictionaryValue> options(new DictionaryValue()); |
48 if (args_->GetSize() > argument_position) { | 48 if (args_->GetSize() > argument_position) { |
49 DictionaryValue* temp_options = NULL; | 49 DictionaryValue* temp_options = NULL; |
50 if (args_->GetDictionary(argument_position, &temp_options)) | 50 if (args_->GetDictionary(argument_position, &temp_options)) { |
51 options.reset(temp_options->DeepCopy()); | 51 options.reset(temp_options->DeepCopy()); |
52 } | |
miket_OOO
2012/04/24 20:49:06
This seems to be a leftover from debugging.
Peng
2012/04/24 21:13:47
Done.
| |
52 } | 53 } |
53 | 54 |
54 // If we tacked on a srcId to the options object, pull it out here to provide | 55 // If we tacked on a srcId to the options object, pull it out here to provide |
55 // to the Socket. | 56 // to the Socket. |
56 int src_id = -1; | 57 int src_id = -1; |
57 if (options->HasKey(kSrcIdKey)) { | 58 if (options->HasKey(kSrcIdKey)) { |
58 EXTENSION_FUNCTION_VALIDATE(options->GetInteger(kSrcIdKey, &src_id)); | 59 EXTENSION_FUNCTION_VALIDATE(options->GetInteger(kSrcIdKey, &src_id)); |
59 } | 60 } |
60 | 61 |
61 return src_id; | 62 return src_id; |
62 } | 63 } |
63 | 64 |
64 APIResourceEventNotifier* AsyncIOAPIFunction::CreateEventNotifier(int src_id) { | 65 APIResourceEventNotifier* AsyncIOAPIFunction::CreateEventNotifier(int src_id) { |
65 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 66 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
66 return new APIResourceEventNotifier( | 67 return new APIResourceEventNotifier( |
67 profile()->GetExtensionEventRouter(), profile(), extension_id(), | 68 profile()->GetExtensionEventRouter(), profile(), extension_id(), |
68 src_id, source_url()); | 69 src_id, source_url()); |
69 } | 70 } |
70 | 71 |
71 APIResourceController* AsyncIOAPIFunction::controller() { | 72 APIResourceController* AsyncIOAPIFunction::controller() { |
72 // ExtensionService's APIResourceController is set exactly once, long before | 73 // ExtensionService's APIResourceController is set exactly once, long before |
73 // this code is reached, so it's safe to access it on either the IO or UI | 74 // this code is reached, so it's safe to access it on either the IO or UI |
74 // thread. | 75 // thread. |
75 return extension_service_->api_resource_controller(); | 76 return extension_service_->api_resource_controller(); |
76 } | 77 } |
77 | 78 |
78 } // namespace extensions | 79 } // namespace extensions |
OLD | NEW |