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

Unified Diff: chrome/browser/extensions/extension_function.h

Issue 8588067: Refactor to allow same code to test both sync and async functions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix dependencies. Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_function.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_function.h
diff --git a/chrome/browser/extensions/extension_function.h b/chrome/browser/extensions/extension_function.h
index 9a0f4e469f76099a110107ed6de01aeb351fd12f..6894c2ce306fe48038e3e317e1a03971701446f3 100644
--- a/chrome/browser/extensions/extension_function.h
+++ b/chrome/browser/extensions/extension_function.h
@@ -208,10 +208,20 @@ class ExtensionFunction
// this category.
class UIThreadExtensionFunction : public ExtensionFunction {
public:
+ // A delegate for use in testing, to intercept the call to SendResponse.
+ class DelegateForTests {
+ public:
+ virtual void OnSendResponse(UIThreadExtensionFunction* function,
+ bool success) = 0;
+ };
+
UIThreadExtensionFunction();
virtual UIThreadExtensionFunction* AsUIThreadExtensionFunction() OVERRIDE;
+ void set_test_delegate(DelegateForTests* delegate) {
+ delegate_ = delegate;
+ }
// Set the profile which contains the extension that has originated this
// function call.
void set_profile(Profile* profile) { profile_ = profile; }
@@ -285,6 +295,8 @@ class UIThreadExtensionFunction : public ExtensionFunction {
virtual void Destruct() const OVERRIDE;
scoped_ptr<RenderViewHostTracker> tracker_;
+
+ DelegateForTests* delegate_;
};
// Extension functions that run on the IO thread. This type of function avoids
@@ -340,24 +352,10 @@ class IOThreadExtensionFunction : public ExtensionFunction {
// the browser's UI thread*.
class AsyncExtensionFunction : public UIThreadExtensionFunction {
public:
- // A delegate for use in testing, to intercept the call to SendResponse.
- class DelegateForTests {
- public:
- virtual void OnSendResponse(AsyncExtensionFunction* function,
- bool success) = 0;
- };
-
AsyncExtensionFunction();
- virtual void SendResponse(bool success) OVERRIDE;
-
- void set_test_delegate(DelegateForTests* delegate) {
- delegate_ = delegate;
- }
protected:
virtual ~AsyncExtensionFunction();
-
- DelegateForTests* delegate_;
};
// A SyncExtensionFunction is an ExtensionFunction that runs synchronously
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_function.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698