| 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 19 matching lines...) Expand all Loading... |
| 30 // | 30 // |
| 31 // TODO(aa): This will have to become reference counted when we introduce | 31 // TODO(aa): This will have to become reference counted when we introduce |
| 32 // APIs that live beyond a single stack frame. | 32 // APIs that live beyond a single stack frame. |
| 33 class ExtensionFunction : public base::RefCounted<ExtensionFunction> { | 33 class ExtensionFunction : public base::RefCounted<ExtensionFunction> { |
| 34 public: | 34 public: |
| 35 ExtensionFunction() : request_id_(-1), name_(""), has_callback_(false) {} | 35 ExtensionFunction() : request_id_(-1), name_(""), has_callback_(false) {} |
| 36 virtual ~ExtensionFunction() {} | 36 virtual ~ExtensionFunction() {} |
| 37 | 37 |
| 38 // Specifies the name of the function. | 38 // Specifies the name of the function. |
| 39 void set_name(const std::string& name) { name_ = name; } | 39 void set_name(const std::string& name) { name_ = name; } |
| 40 const std::string name() const { return name_; } | 40 const std::string name() { return name_; } |
| 41 | 41 |
| 42 // Specifies the raw arguments to the function, as a JSON value. | 42 // Specifies the raw arguments to the function, as a JSON value. |
| 43 virtual void SetArgs(const Value* args) = 0; | 43 virtual void SetArgs(const Value* args) = 0; |
| 44 | 44 |
| 45 // Retrieves the results of the function as a JSON-encoded string (may | 45 // Retrieves the results of the function as a JSON-encoded string (may |
| 46 // be empty). | 46 // be empty). |
| 47 virtual const std::string GetResult() = 0; | 47 virtual const std::string GetResult() = 0; |
| 48 | 48 |
| 49 // Retrieves any error string from the function. | 49 // Retrieves any error string from the function. |
| 50 virtual const std::string GetError() = 0; | 50 virtual const std::string GetError() = 0; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 | 162 |
| 163 virtual void Run() { | 163 virtual void Run() { |
| 164 SendResponse(RunImpl()); | 164 SendResponse(RunImpl()); |
| 165 } | 165 } |
| 166 | 166 |
| 167 private: | 167 private: |
| 168 DISALLOW_COPY_AND_ASSIGN(SyncExtensionFunction); | 168 DISALLOW_COPY_AND_ASSIGN(SyncExtensionFunction); |
| 169 }; | 169 }; |
| 170 | 170 |
| 171 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_H_ | 171 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_H_ |
| OLD | NEW |