OLD | NEW |
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 "base/files/scoped_temp_dir.h" | 5 #include "base/files/scoped_temp_dir.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "content/browser/browser_thread_impl.h" | 8 #include "content/browser/browser_thread_impl.h" |
9 #include "content/browser/fileapi/mock_url_request_delegate.h" | 9 #include "content/browser/fileapi/mock_url_request_delegate.h" |
10 #include "content/browser/service_worker/embedded_worker_test_helper.h" | 10 #include "content/browser/service_worker/embedded_worker_test_helper.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 void SetUp() override { | 45 void SetUp() override { |
46 helper_.reset( | 46 helper_.reset( |
47 new EmbeddedWorkerTestHelper(base::FilePath(), kMockRenderProcessId)); | 47 new EmbeddedWorkerTestHelper(base::FilePath(), kMockRenderProcessId)); |
48 | 48 |
49 // A new unstored registration/version. | 49 // A new unstored registration/version. |
50 scope_ = GURL("http://host/scope/"); | 50 scope_ = GURL("http://host/scope/"); |
51 script_url_ = GURL("http://host/script.js"); | 51 script_url_ = GURL("http://host/script.js"); |
52 registration_ = new ServiceWorkerRegistration( | 52 registration_ = new ServiceWorkerRegistration( |
53 scope_, 1L, context()->AsWeakPtr()); | 53 scope_, 1L, context()->AsWeakPtr()); |
54 version_ = new ServiceWorkerVersion( | 54 version_ = new ServiceWorkerVersion( |
55 registration_.get(), script_url_, 1L, context()->AsWeakPtr()); | 55 registration_.get(), script_url_, |
| 56 std::string("6d0465ba-40af-4e15-bc92-e57c73de08cf"), |
| 57 context()->AsWeakPtr()); |
56 | 58 |
57 std::vector<ServiceWorkerDatabase::ResourceRecord> records; | 59 std::vector<ServiceWorkerDatabase::ResourceRecord> records; |
58 records.push_back( | 60 records.push_back( |
59 ServiceWorkerDatabase::ResourceRecord(10, version_->script_url(), 100)); | 61 ServiceWorkerDatabase::ResourceRecord(10, version_->script_url(), 100)); |
60 version_->script_cache_map()->SetResources(records); | 62 version_->script_cache_map()->SetResources(records); |
61 | 63 |
62 // An empty host. | 64 // An empty host. |
63 scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( | 65 scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( |
64 kMockRenderProcessId, MSG_ROUTING_NONE, kMockProviderId, | 66 kMockRenderProcessId, MSG_ROUTING_NONE, kMockProviderId, |
65 SERVICE_WORKER_PROVIDER_FOR_WINDOW, context()->AsWeakPtr(), NULL)); | 67 SERVICE_WORKER_PROVIDER_FOR_WINDOW, context()->AsWeakPtr(), NULL)); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 // Shouldn't crash if the ProviderHost is deleted prior to completion of | 239 // Shouldn't crash if the ProviderHost is deleted prior to completion of |
238 // the database lookup. | 240 // the database lookup. |
239 context()->RemoveProviderHost(kMockRenderProcessId, kMockProviderId); | 241 context()->RemoveProviderHost(kMockRenderProcessId, kMockProviderId); |
240 EXPECT_FALSE(provider_host_.get()); | 242 EXPECT_FALSE(provider_host_.get()); |
241 base::RunLoop().RunUntilIdle(); | 243 base::RunLoop().RunUntilIdle(); |
242 EXPECT_TRUE(sw_job->ShouldFallbackToNetwork()); | 244 EXPECT_TRUE(sw_job->ShouldFallbackToNetwork()); |
243 EXPECT_FALSE(sw_job->ShouldForwardToServiceWorker()); | 245 EXPECT_FALSE(sw_job->ShouldForwardToServiceWorker()); |
244 } | 246 } |
245 | 247 |
246 } // namespace content | 248 } // namespace content |
OLD | NEW |