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

Side by Side Diff: content/browser/service_worker/embedded_worker_test_helper.h

Issue 2933793002: ServiceWorker: keep dispatcher hosts for unittests in the test helper (Closed)
Patch Set: RegisterMockDispatcherHost -> RegisterDispatcherHost Created 3 years, 6 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/service_worker/embedded_worker_test_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 bool Send(IPC::Message* message) override; 112 bool Send(IPC::Message* message) override;
113 113
114 // IPC::Listener implementation. 114 // IPC::Listener implementation.
115 bool OnMessageReceived(const IPC::Message& msg) override; 115 bool OnMessageReceived(const IPC::Message& msg) override;
116 116
117 // Register a mojo endpoint object derived from 117 // Register a mojo endpoint object derived from
118 // MockEmbeddedWorkerInstanceClient. 118 // MockEmbeddedWorkerInstanceClient.
119 void RegisterMockInstanceClient( 119 void RegisterMockInstanceClient(
120 std::unique_ptr<MockEmbeddedWorkerInstanceClient> client); 120 std::unique_ptr<MockEmbeddedWorkerInstanceClient> client);
121 121
122 // Registers the dispatcher host for the process to a map managed by this test
123 // helper. If there is a existing dispatcher host, it'll removed before adding
124 // to the map. This should be called before ServiceWorkerDispatcherHost::Init
125 // because it internally calls ServiceWorkerContextCore::AddDispatcherHost.
126 // If |dispatcher_host| is nullptr, this method just removes the existing
127 // dispatcher host from the map.
128 void RegisterDispatcherHost(
129 int process_id,
130 scoped_refptr<ServiceWorkerDispatcherHost> dispatcher_host);
131
122 template <typename MockType, typename... Args> 132 template <typename MockType, typename... Args>
123 MockType* CreateAndRegisterMockInstanceClient(Args&&... args); 133 MockType* CreateAndRegisterMockInstanceClient(Args&&... args);
124 134
125 // IPC sink for EmbeddedWorker messages. 135 // IPC sink for EmbeddedWorker messages.
126 IPC::TestSink* ipc_sink() { return &sink_; } 136 IPC::TestSink* ipc_sink() { return &sink_; }
127 137
128 std::vector<Event>* dispatched_events() { return &events_; } 138 std::vector<Event>* dispatched_events() { return &events_; }
129 139
130 std::vector<std::unique_ptr<MockEmbeddedWorkerInstanceClient>>* 140 std::vector<std::unique_ptr<MockEmbeddedWorkerInstanceClient>>*
131 mock_instance_clients() { 141 mock_instance_clients() {
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 std::unique_ptr<MockType> mock = 375 std::unique_ptr<MockType> mock =
366 base::MakeUnique<MockType>(std::forward<Args>(args)...); 376 base::MakeUnique<MockType>(std::forward<Args>(args)...);
367 MockType* mock_rawptr = mock.get(); 377 MockType* mock_rawptr = mock.get();
368 RegisterMockInstanceClient(std::move(mock)); 378 RegisterMockInstanceClient(std::move(mock));
369 return mock_rawptr; 379 return mock_rawptr;
370 } 380 }
371 381
372 } // namespace content 382 } // namespace content
373 383
374 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ 384 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/service_worker/embedded_worker_test_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698