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

Side by Side Diff: content/browser/service_worker/service_worker_request_handler_unittest.cc

Issue 2638313002: Manage ServiceWorkerDispatcherHost in ServiceWorkerContextCore (Closed)
Patch Set: Rebase Created 3 years, 10 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 #include "content/browser/service_worker/service_worker_request_handler.h" 5 #include "content/browser/service_worker/service_worker_request_handler.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "content/browser/fileapi/mock_url_request_delegate.h" 10 #include "content/browser/fileapi/mock_url_request_delegate.h"
(...skipping 24 matching lines...) Expand all
35 35
36 class ServiceWorkerRequestHandlerTest : public testing::Test { 36 class ServiceWorkerRequestHandlerTest : public testing::Test {
37 public: 37 public:
38 ServiceWorkerRequestHandlerTest() 38 ServiceWorkerRequestHandlerTest()
39 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {} 39 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {}
40 40
41 void SetUp() override { 41 void SetUp() override {
42 helper_.reset(new EmbeddedWorkerTestHelper(base::FilePath())); 42 helper_.reset(new EmbeddedWorkerTestHelper(base::FilePath()));
43 43
44 // An empty host. 44 // An empty host.
45 std::unique_ptr<ServiceWorkerProviderHost> host( 45 std::unique_ptr<ServiceWorkerProviderHost> host =
46 new ServiceWorkerProviderHost( 46 CreateProviderHostForWindow(
47 helper_->mock_render_process_id(), MSG_ROUTING_NONE, 47 helper_->mock_render_process_id(), kMockProviderId,
48 kMockProviderId, SERVICE_WORKER_PROVIDER_FOR_WINDOW, 48 true /* is_parent_frame_secure */, context()->AsWeakPtr());
49 ServiceWorkerProviderHost::FrameSecurityLevel::SECURE,
50 context()->AsWeakPtr(), nullptr));
51 provider_host_ = host->AsWeakPtr(); 49 provider_host_ = host->AsWeakPtr();
52 context()->AddProviderHost(std::move(host)); 50 context()->AddProviderHost(std::move(host));
53
54 } 51 }
55 52
56 void TearDown() override { 53 void TearDown() override {
57 helper_.reset(); 54 helper_.reset();
58 } 55 }
59 56
60 ServiceWorkerContextCore* context() const { return helper_->context(); } 57 ServiceWorkerContextCore* context() const { return helper_->context(); }
61 ServiceWorkerContextWrapper* context_wrapper() const { 58 ServiceWorkerContextWrapper* context_wrapper() const {
62 return helper_->context_wrapper(); 59 return helper_->context_wrapper();
63 } 60 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 // Check provider host's URL after initializing a handler for an image. 158 // Check provider host's URL after initializing a handler for an image.
162 provider_host_->SetDocumentUrl(GURL("https://host/scope/doc")); 159 provider_host_->SetDocumentUrl(GURL("https://host/scope/doc"));
163 std::unique_ptr<net::URLRequest> request = 160 std::unique_ptr<net::URLRequest> request =
164 CreateRequest("https://host/scope/image", "GET"); 161 CreateRequest("https://host/scope/image", "GET");
165 InitializeHandler(request.get(), true, RESOURCE_TYPE_IMAGE); 162 InitializeHandler(request.get(), true, RESOURCE_TYPE_IMAGE);
166 ASSERT_FALSE(GetHandler(request.get())); 163 ASSERT_FALSE(GetHandler(request.get()));
167 EXPECT_EQ(GURL("https://host/scope/doc"), provider_host_->document_url()); 164 EXPECT_EQ(GURL("https://host/scope/doc"), provider_host_->document_url());
168 } 165 }
169 166
170 } // namespace content 167 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698