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 #ifndef CHROME_BROWSER_EXTENSIONS_API_API_FUNCTION_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_API_FUNCTION_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_API_FUNCTION_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_API_FUNCTION_H_ |
7 | 7 |
8 #include "chrome/browser/extensions/extension_function.h" | 8 #include "chrome/browser/extensions/extension_function.h" |
9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
10 | 10 |
11 namespace extensions { | 11 namespace extensions { |
12 | 12 |
13 class ApiResourceEventNotifier; | 13 // Base class for API functions. TODO(miket): there isn't much here anymore |
14 | 14 // since the removal of ApiResourceEventRouter. Should we promote all its |
| 15 // subclasses to UIThreadExtensionFunctions? |
15 class ApiFunction : public UIThreadExtensionFunction { | 16 class ApiFunction : public UIThreadExtensionFunction { |
16 protected: | 17 protected: |
17 ApiFunction(); | 18 ApiFunction(); |
18 virtual ~ApiFunction(); | 19 virtual ~ApiFunction(); |
19 | |
20 // Looks for a kSrcId key that might have been added to a create method's | |
21 // options object. | |
22 int ExtractSrcId(const DictionaryValue* options); | |
23 | |
24 // Utility. | |
25 ApiResourceEventNotifier* CreateEventNotifier(int src_id); | |
26 }; | 20 }; |
27 | 21 |
28 // AsyncApiFunction provides convenient thread management for APIs that need to | 22 // AsyncApiFunction provides convenient thread management for APIs that need to |
29 // do essentially all their work on a thread other than the UI thread. | 23 // do essentially all their work on a thread other than the UI thread. |
30 class AsyncApiFunction : public ApiFunction { | 24 class AsyncApiFunction : public ApiFunction { |
31 protected: | 25 protected: |
32 AsyncApiFunction(); | 26 AsyncApiFunction(); |
33 virtual ~AsyncApiFunction(); | 27 virtual ~AsyncApiFunction(); |
34 | 28 |
35 // Like Prepare(). A useful place to put common work in an ApiFunction | 29 // Like Prepare(). A useful place to put common work in an ApiFunction |
(...skipping 30 matching lines...) Expand all Loading... |
66 void RespondOnUIThread(); | 60 void RespondOnUIThread(); |
67 | 61 |
68 // If you don't want your Work() method to happen on the IO thread, then set | 62 // If you don't want your Work() method to happen on the IO thread, then set |
69 // this to the thread that you do want, preferably in Prepare(). | 63 // this to the thread that you do want, preferably in Prepare(). |
70 content::BrowserThread::ID work_thread_id_; | 64 content::BrowserThread::ID work_thread_id_; |
71 }; | 65 }; |
72 | 66 |
73 } // namespace extensions | 67 } // namespace extensions |
74 | 68 |
75 #endif // CHROME_BROWSER_EXTENSIONS_API_API_FUNCTION_H_ | 69 #endif // CHROME_BROWSER_EXTENSIONS_API_API_FUNCTION_H_ |
OLD | NEW |