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

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: Remove content:: 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 void RegisterMockDispatcherHost(
falken 2017/06/12 06:37:32 I think we don't need to say Mock since it takes a
shimazu 2017/06/12 06:51:08 I prefer saying Mock here because unittests should
falken 2017/06/12 07:08:20 I think it's confusing because all the other occur
shimazu 2017/06/12 08:04:07 I see, I agree with that.
127 int process_id,
128 scoped_refptr<ServiceWorkerDispatcherHost> dispatcher_host);
129
122 template <typename MockType, typename... Args> 130 template <typename MockType, typename... Args>
123 MockType* CreateAndRegisterMockInstanceClient(Args&&... args); 131 MockType* CreateAndRegisterMockInstanceClient(Args&&... args);
124 132
125 // IPC sink for EmbeddedWorker messages. 133 // IPC sink for EmbeddedWorker messages.
126 IPC::TestSink* ipc_sink() { return &sink_; } 134 IPC::TestSink* ipc_sink() { return &sink_; }
127 135
128 std::vector<Event>* dispatched_events() { return &events_; } 136 std::vector<Event>* dispatched_events() { return &events_; }
129 137
130 std::vector<std::unique_ptr<MockEmbeddedWorkerInstanceClient>>* 138 std::vector<std::unique_ptr<MockEmbeddedWorkerInstanceClient>>*
131 mock_instance_clients() { 139 mock_instance_clients() {
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 std::unique_ptr<MockType> mock = 373 std::unique_ptr<MockType> mock =
366 base::MakeUnique<MockType>(std::forward<Args>(args)...); 374 base::MakeUnique<MockType>(std::forward<Args>(args)...);
367 MockType* mock_rawptr = mock.get(); 375 MockType* mock_rawptr = mock.get();
368 RegisterMockInstanceClient(std::move(mock)); 376 RegisterMockInstanceClient(std::move(mock));
369 return mock_rawptr; 377 return mock_rawptr;
370 } 378 }
371 379
372 } // namespace content 380 } // namespace content
373 381
374 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ 382 #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