OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "content/browser/service_worker/service_worker_dispatcher_host.h" | 5 #include "content/browser/service_worker/service_worker_dispatcher_host.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "content/browser/browser_thread_impl.h" | 10 #include "content/browser/browser_thread_impl.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 static void SaveStatusCallback(bool* called, | 28 static void SaveStatusCallback(bool* called, |
29 ServiceWorkerStatusCode* out, | 29 ServiceWorkerStatusCode* out, |
30 ServiceWorkerStatusCode status) { | 30 ServiceWorkerStatusCode status) { |
31 *called = true; | 31 *called = true; |
32 *out = status; | 32 *out = status; |
33 } | 33 } |
34 | 34 |
35 } | 35 } |
36 | 36 |
37 static const int kRenderProcessId = 1; | 37 static const int kRenderProcessId = 1; |
| 38 static const int kRenderFrameId = 1; |
38 | 39 |
39 class TestingServiceWorkerDispatcherHost : public ServiceWorkerDispatcherHost { | 40 class TestingServiceWorkerDispatcherHost : public ServiceWorkerDispatcherHost { |
40 public: | 41 public: |
41 TestingServiceWorkerDispatcherHost( | 42 TestingServiceWorkerDispatcherHost( |
42 int process_id, | 43 int process_id, |
43 ServiceWorkerContextWrapper* context_wrapper, | 44 ServiceWorkerContextWrapper* context_wrapper, |
44 ResourceContext* resource_context, | 45 ResourceContext* resource_context, |
45 EmbeddedWorkerTestHelper* helper) | 46 EmbeddedWorkerTestHelper* helper) |
46 : ServiceWorkerDispatcherHost(process_id, NULL, resource_context), | 47 : ServiceWorkerDispatcherHost(process_id, NULL, resource_context), |
47 bad_messages_received_count_(0), | 48 bad_messages_received_count_(0), |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 GURL document_url, | 123 GURL document_url, |
123 uint32 expected_message) { | 124 uint32 expected_message) { |
124 SendGetRegistration(provider_id, document_url); | 125 SendGetRegistration(provider_id, document_url); |
125 EXPECT_TRUE(dispatcher_host_->ipc_sink()->GetUniqueMessageMatching( | 126 EXPECT_TRUE(dispatcher_host_->ipc_sink()->GetUniqueMessageMatching( |
126 expected_message)); | 127 expected_message)); |
127 dispatcher_host_->ipc_sink()->ClearMessages(); | 128 dispatcher_host_->ipc_sink()->ClearMessages(); |
128 } | 129 } |
129 | 130 |
130 ServiceWorkerProviderHost* CreateServiceWorkerProviderHost(int provider_id) { | 131 ServiceWorkerProviderHost* CreateServiceWorkerProviderHost(int provider_id) { |
131 return new ServiceWorkerProviderHost(kRenderProcessId, | 132 return new ServiceWorkerProviderHost(kRenderProcessId, |
132 MSG_ROUTING_NONE, | 133 kRenderFrameId, |
133 provider_id, | 134 provider_id, |
134 context()->AsWeakPtr(), | 135 context()->AsWeakPtr(), |
135 dispatcher_host_.get()); | 136 dispatcher_host_.get()); |
136 } | 137 } |
137 | 138 |
138 | 139 |
139 TestBrowserThreadBundle browser_thread_bundle_; | 140 TestBrowserThreadBundle browser_thread_bundle_; |
140 content::MockResourceContext resource_context_; | 141 content::MockResourceContext resource_context_; |
141 scoped_ptr<EmbeddedWorkerTestHelper> helper_; | 142 scoped_ptr<EmbeddedWorkerTestHelper> helper_; |
142 scoped_refptr<TestingServiceWorkerDispatcherHost> dispatcher_host_; | 143 scoped_refptr<TestingServiceWorkerDispatcherHost> dispatcher_host_; |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 | 492 |
492 // To show the new dispatcher can operate, simulate provider creation. Since | 493 // To show the new dispatcher can operate, simulate provider creation. Since |
493 // the old dispatcher cleaned up the old provider host, the new one won't | 494 // the old dispatcher cleaned up the old provider host, the new one won't |
494 // complain. | 495 // complain. |
495 new_dispatcher_host->OnMessageReceived( | 496 new_dispatcher_host->OnMessageReceived( |
496 ServiceWorkerHostMsg_ProviderCreated(kProviderId, MSG_ROUTING_NONE)); | 497 ServiceWorkerHostMsg_ProviderCreated(kProviderId, MSG_ROUTING_NONE)); |
497 EXPECT_EQ(0, new_dispatcher_host->bad_messages_received_count_); | 498 EXPECT_EQ(0, new_dispatcher_host->bad_messages_received_count_); |
498 } | 499 } |
499 | 500 |
500 } // namespace content | 501 } // namespace content |
OLD | NEW |