| 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" |
| 11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
| 12 #include "base/ref_counted.h" | 12 #include "base/ref_counted.h" |
| 13 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 13 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
| 14 | 14 |
| 15 class ExtensionFunctionDispatcher; | 15 class ExtensionFunctionDispatcher; |
| 16 class Profile; | 16 class Profile; |
| 17 | 17 |
| 18 #define EXTENSION_FUNCTION_VALIDATE(test) do { \ | 18 #define EXTENSION_FUNCTION_VALIDATE(test) do { \ |
| 19 if (!(test)) { \ | 19 if (!(test)) { \ |
| 20 bad_message_ = true; \ | 20 bad_message_ = true; \ |
| 21 return false; \ | 21 return false; \ |
| 22 } \ | 22 } \ |
| 23 } while (0) | 23 } while (0) |
| 24 | 24 |
| 25 #define DECLARE_EXTENSION_FUNCTION_NAME(name) \ |
| 26 public: static const char* function_name() { return name; } |
| 27 |
| 25 // Abstract base class for extension functions the ExtensionFunctionDispatcher | 28 // Abstract base class for extension functions the ExtensionFunctionDispatcher |
| 26 // knows how to dispatch to. | 29 // knows how to dispatch to. |
| 27 // | 30 // |
| 28 // 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 |
| 29 // APIs that live beyond a single stack frame. | 32 // APIs that live beyond a single stack frame. |
| 30 class ExtensionFunction : public base::RefCounted<ExtensionFunction> { | 33 class ExtensionFunction : public base::RefCounted<ExtensionFunction> { |
| 31 public: | 34 public: |
| 32 ExtensionFunction() : request_id_(-1), name_(""), has_callback_(false) {} | 35 ExtensionFunction() : request_id_(-1), name_(""), has_callback_(false) {} |
| 33 virtual ~ExtensionFunction() {} | 36 virtual ~ExtensionFunction() {} |
| 34 | 37 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 162 |
| 160 virtual void Run() { | 163 virtual void Run() { |
| 161 SendResponse(RunImpl()); | 164 SendResponse(RunImpl()); |
| 162 } | 165 } |
| 163 | 166 |
| 164 private: | 167 private: |
| 165 DISALLOW_COPY_AND_ASSIGN(SyncExtensionFunction); | 168 DISALLOW_COPY_AND_ASSIGN(SyncExtensionFunction); |
| 166 }; | 169 }; |
| 167 | 170 |
| 168 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_H_ | 171 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_H_ |
| OLD | NEW |