Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: chrome/browser/extensions/api/api_function.cc

Issue 11116016: Hook up API to notification_ui_manager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: asargent review suggestion Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 10
11 using content::BrowserThread; 11 using content::BrowserThread;
12 12
13 namespace extensions { 13 namespace extensions {
14 14
15 ApiFunction::ApiFunction() {
16 }
17
18 ApiFunction::~ApiFunction() {
19 }
20
21 int ApiFunction::ExtractSrcId(const DictionaryValue* options) {
22 int src_id = -1;
23 if (options) {
24 if (options->HasKey(kSrcIdKey))
25 EXTENSION_FUNCTION_VALIDATE(options->GetInteger(kSrcIdKey, &src_id));
26 }
27 return src_id;
28 }
29
30 ApiResourceEventNotifier* ApiFunction::CreateEventNotifier(int src_id) {
31 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
32 return new ApiResourceEventNotifier(
33 profile()->GetExtensionEventRouter(), profile(), extension_id(),
34 src_id, source_url());
35 }
36
37 // AsyncApiFunction
15 AsyncApiFunction::AsyncApiFunction() 38 AsyncApiFunction::AsyncApiFunction()
16 : work_thread_id_(BrowserThread::IO) { 39 : work_thread_id_(BrowserThread::IO) {
17 } 40 }
18 41
19 AsyncApiFunction::~AsyncApiFunction() { 42 AsyncApiFunction::~AsyncApiFunction() {
20 } 43 }
21 44
22 bool AsyncApiFunction::RunImpl() { 45 bool AsyncApiFunction::RunImpl() {
23 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 46 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
24 47
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 "the UI thread. This nullifies the point of this class. Either " 85 "the UI thread. This nullifies the point of this class. Either "
63 "specify a different thread or derive from a different class."; 86 "specify a different thread or derive from a different class.";
64 AsyncWorkStart(); 87 AsyncWorkStart();
65 } 88 }
66 89
67 void AsyncApiFunction::RespondOnUIThread() { 90 void AsyncApiFunction::RespondOnUIThread() {
68 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 91 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
69 SendResponse(Respond()); 92 SendResponse(Respond());
70 } 93 }
71 94
72 int AsyncApiFunction::ExtractSrcId(const DictionaryValue* options) {
73 int src_id = -1;
74 if (options) {
75 if (options->HasKey(kSrcIdKey))
76 EXTENSION_FUNCTION_VALIDATE(options->GetInteger(kSrcIdKey, &src_id));
77 }
78 return src_id;
79 }
80
81 ApiResourceEventNotifier* AsyncApiFunction::CreateEventNotifier(int src_id) {
82 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
83 return new ApiResourceEventNotifier(
84 profile()->GetExtensionEventRouter(), profile(), extension_id(),
85 src_id, source_url());
86 }
87
88 } // namespace extensions 95 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/api_function.h ('k') | chrome/browser/extensions/api/notification/notification_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698