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

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

Issue 252633003: Introduce worker_devtools_agent_route_id for EmbeddedWorker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit tests failure Created 6 years, 8 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
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 <vector> 8 #include <vector>
9 9
10 #include "base/atomic_sequence_num.h"
10 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/memory/ref_counted.h"
11 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
12 #include "ipc/ipc_listener.h" 14 #include "ipc/ipc_listener.h"
13 #include "ipc/ipc_test_sink.h" 15 #include "ipc/ipc_test_sink.h"
14 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
15 #include "url/gurl.h" 17 #include "url/gurl.h"
16 18
17 class GURL; 19 class GURL;
18 20
19 namespace content { 21 namespace content {
20 22
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 // These functions simulate sending an EmbeddedHostMsg message to the 94 // These functions simulate sending an EmbeddedHostMsg message to the
93 // browser. 95 // browser.
94 void SimulateWorkerStarted(int thread_id, int embedded_worker_id); 96 void SimulateWorkerStarted(int thread_id, int embedded_worker_id);
95 void SimulateWorkerStopped(int embedded_worker_id); 97 void SimulateWorkerStopped(int embedded_worker_id);
96 void SimulateSend(IPC::Message* message); 98 void SimulateSend(IPC::Message* message);
97 99
98 protected: 100 protected:
99 EmbeddedWorkerRegistry* registry(); 101 EmbeddedWorkerRegistry* registry();
100 102
101 private: 103 private:
104 class NextRoutingId : public base::RefCountedThreadSafe<NextRoutingId> {
105 public:
106 NextRoutingId() {}
107 int GetNext() { return atomic_sequence_number_.GetNext(); }
108
109 private:
110 friend class base::RefCountedThreadSafe<NextRoutingId>;
111 ~NextRoutingId() {}
112 base::AtomicSequenceNumber atomic_sequence_number_;
113 };
114
102 void OnStartWorkerStub(int embedded_worker_id, 115 void OnStartWorkerStub(int embedded_worker_id,
103 int64 service_worker_version_id, 116 int64 service_worker_version_id,
104 const GURL& scope, 117 const GURL& scope,
105 const GURL& script_url); 118 const GURL& script_url,
119 int worker_devtools_agent_route_id);
106 void OnStopWorkerStub(int embedded_worker_id); 120 void OnStopWorkerStub(int embedded_worker_id);
107 void OnMessageToWorkerStub(int thread_id, 121 void OnMessageToWorkerStub(int thread_id,
108 int embedded_worker_id, 122 int embedded_worker_id,
109 const IPC::Message& message); 123 const IPC::Message& message);
110 void OnActivateEventStub(int request_id); 124 void OnActivateEventStub(int request_id);
111 void OnInstallEventStub(int request_id, int active_version_id); 125 void OnInstallEventStub(int request_id, int active_version_id);
112 void OnFetchEventStub(int request_id, 126 void OnFetchEventStub(int request_id,
113 const ServiceWorkerFetchRequest& request); 127 const ServiceWorkerFetchRequest& request);
114 128
115 base::WeakPtr<ServiceWorkerContextCore> context_; 129 base::WeakPtr<ServiceWorkerContextCore> context_;
116 130
117 IPC::TestSink sink_; 131 IPC::TestSink sink_;
118 IPC::TestSink inner_sink_; 132 IPC::TestSink inner_sink_;
119 133
120 int next_thread_id_; 134 int next_thread_id_;
121 135
122 // Updated each time MessageToWorker message is received. 136 // Updated each time MessageToWorker message is received.
123 int current_embedded_worker_id_; 137 int current_embedded_worker_id_;
124 138
139 scoped_refptr<NextRoutingId> next_routing_id_;
140
125 base::WeakPtrFactory<EmbeddedWorkerTestHelper> weak_factory_; 141 base::WeakPtrFactory<EmbeddedWorkerTestHelper> weak_factory_;
126 142
127 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerTestHelper); 143 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerTestHelper);
128 }; 144 };
129 145
130 } // namespace content 146 } // namespace content
131 147
132 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ 148 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698