| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ |
| 6 #define CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 class EmbeddedWorkerTestHelper : public IPC::Sender, | 42 class EmbeddedWorkerTestHelper : public IPC::Sender, |
| 43 public IPC::Listener { | 43 public IPC::Listener { |
| 44 public: | 44 public: |
| 45 EmbeddedWorkerTestHelper(ServiceWorkerContextCore* context); | 45 EmbeddedWorkerTestHelper(ServiceWorkerContextCore* context); |
| 46 virtual ~EmbeddedWorkerTestHelper(); | 46 virtual ~EmbeddedWorkerTestHelper(); |
| 47 | 47 |
| 48 // Call this to simulate add/associate a process to a worker. | 48 // Call this to simulate add/associate a process to a worker. |
| 49 void SimulateAddProcess(int embedded_worker_id, int process_id); | 49 void SimulateAddProcess(int embedded_worker_id, int process_id); |
| 50 void SimulateRemoveProcess(int embedded_worker_id, int process_id); | 50 void SimulateRemoveProcess(int embedded_worker_id, int process_id); |
| 51 | 51 |
| 52 // Call to create a new worker and also associate a process to |
| 53 // it. Returns the new embedded worker id which can be used for |
| 54 // SimulateRemoveProcess. |
| 55 int SimulateCreateWorker(int process_id); |
| 56 |
| 52 // IPC::Sender implementation. | 57 // IPC::Sender implementation. |
| 53 virtual bool Send(IPC::Message* message) OVERRIDE; | 58 virtual bool Send(IPC::Message* message) OVERRIDE; |
| 54 | 59 |
| 55 // IPC::Listener implementation. | 60 // IPC::Listener implementation. |
| 56 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | 61 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
| 57 | 62 |
| 58 IPC::TestSink* ipc_sink() { return &sink_; } | 63 IPC::TestSink* ipc_sink() { return &sink_; } |
| 59 | 64 |
| 60 protected: | 65 protected: |
| 61 // Called when StartWorker, StopWorker and SendMessageToWorker message | 66 // Called when StartWorker, StopWorker and SendMessageToWorker message |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 int next_thread_id_; | 103 int next_thread_id_; |
| 99 std::vector<IPC::Message> messages_; | 104 std::vector<IPC::Message> messages_; |
| 100 base::WeakPtrFactory<EmbeddedWorkerTestHelper> weak_factory_; | 105 base::WeakPtrFactory<EmbeddedWorkerTestHelper> weak_factory_; |
| 101 | 106 |
| 102 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerTestHelper); | 107 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerTestHelper); |
| 103 }; | 108 }; |
| 104 | 109 |
| 105 } // namespace content | 110 } // namespace content |
| 106 | 111 |
| 107 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ | 112 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ |
| OLD | NEW |