Index: extensions/renderer/api_test_base.h |
diff --git a/extensions/renderer/api_test_base.h b/extensions/renderer/api_test_base.h |
index c9a23e352430281f3eedd1f167157c7415ec0e0a..f5bd0fc94de84e318f15954e1540bc70ca605d96 100644 |
--- a/extensions/renderer/api_test_base.h |
+++ b/extensions/renderer/api_test_base.h |
@@ -11,6 +11,7 @@ |
#include "base/message_loop/message_loop.h" |
#include "base/run_loop.h" |
+#include "extensions/common/mojo/keep_alive.mojom.h" |
#include "extensions/renderer/module_system_test.h" |
#include "extensions/renderer/v8_schema_registry.h" |
#include "gin/handle.h" |
@@ -61,6 +62,28 @@ class TestServiceProvider : public gin::Wrappable<TestServiceProvider> { |
service_factories_; |
}; |
+// A counter for the number of keep alives requested. |
+class KeepAliveCounter { |
Ken Rockot(use gerrit already)
2014/10/24 18:29:54
nit: What do you think about moving KeepAliveCount
Sam McNally
2014/10/27 05:07:24
TestServiceProvider is fairly tightly coupled to A
|
+ public: |
+ KeepAliveCounter(); |
+ |
+ void CreateKeepAlive(mojo::InterfaceRequest<KeepAlive> request); |
+ void WaitUntilKeepAlivesFinish(); |
+ |
+ int keep_alives() { return keep_alives_; } |
+ int keep_alive_ends() { return keep_alive_ends_; } |
+ |
+ private: |
+ class Instance; |
+ |
+ void PollKeepAlives(const base::Closure& quit_closure); |
+ |
+ int keep_alives_; |
+ int keep_alive_ends_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(KeepAliveCounter); |
+}; |
+ |
// A base class for unit testing apps/extensions API custom bindings implemented |
// on Mojo services. To use: |
// 1. Register test Mojo service implementations on service_provider(). |
@@ -76,6 +99,7 @@ class ApiTestBase : public ModuleSystemTest { |
virtual void SetUp() override; |
void RunTest(const std::string& file_name, const std::string& test_name); |
TestServiceProvider* service_provider() { return service_provider_; } |
+ KeepAliveCounter& keep_alive_counter() { return keep_alive_counter_; } |
private: |
void RegisterModules(); |
@@ -87,6 +111,7 @@ class ApiTestBase : public ModuleSystemTest { |
base::MessageLoop message_loop_; |
TestServiceProvider* service_provider_; |
scoped_ptr<V8SchemaRegistry> v8_schema_registry_; |
+ KeepAliveCounter keep_alive_counter_; |
}; |
} // namespace extensions |