| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_EXTENSION_FUNCTION_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 void set_has_callback(bool has_callback) { has_callback_ = has_callback; } | 59 void set_has_callback(bool has_callback) { has_callback_ = has_callback; } |
| 60 bool has_callback() { return has_callback_; } | 60 bool has_callback() { return has_callback_; } |
| 61 | 61 |
| 62 // Execute the API. Clients should call set_raw_args() and | 62 // Execute the API. Clients should call set_raw_args() and |
| 63 // set_request_id() before calling this method. Derived classes should be | 63 // set_request_id() before calling this method. Derived classes should be |
| 64 // ready to return raw_result() and error() before returning from this | 64 // ready to return raw_result() and error() before returning from this |
| 65 // function. | 65 // function. |
| 66 virtual void Run() = 0; | 66 virtual void Run() = 0; |
| 67 | 67 |
| 68 protected: | 68 protected: |
| 69 // Gets the extension that called this function. This can return NULL for |
| 70 // async functions. |
| 71 Extension* GetExtension() { |
| 72 if (dispatcher()) |
| 73 return dispatcher()->GetExtension(); |
| 74 else |
| 75 return NULL; |
| 76 } |
| 77 |
| 69 // The peer to the dispatcher that will service this extension function call. | 78 // The peer to the dispatcher that will service this extension function call. |
| 70 scoped_refptr<ExtensionFunctionDispatcher::Peer> peer_; | 79 scoped_refptr<ExtensionFunctionDispatcher::Peer> peer_; |
| 71 | 80 |
| 72 // Id of this request, used to map the response back to the caller. | 81 // Id of this request, used to map the response back to the caller. |
| 73 int request_id_; | 82 int request_id_; |
| 74 | 83 |
| 75 // The name of this function. | 84 // The name of this function. |
| 76 std::string name_; | 85 std::string name_; |
| 77 | 86 |
| 78 // True if the js caller provides a callback function to receive the response | 87 // True if the js caller provides a callback function to receive the response |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 | 159 |
| 151 virtual void Run() { | 160 virtual void Run() { |
| 152 SendResponse(RunImpl()); | 161 SendResponse(RunImpl()); |
| 153 } | 162 } |
| 154 | 163 |
| 155 private: | 164 private: |
| 156 DISALLOW_COPY_AND_ASSIGN(SyncExtensionFunction); | 165 DISALLOW_COPY_AND_ASSIGN(SyncExtensionFunction); |
| 157 }; | 166 }; |
| 158 | 167 |
| 159 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_H_ | 168 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_H_ |
| OLD | NEW |