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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 net::DEFAULT_PRIORITY, | 90 net::DEFAULT_PRIORITY, |
91 &url_request_delegate_, | 91 &url_request_delegate_, |
92 NULL); | 92 NULL); |
93 scoped_ptr<ServiceWorkerContextRequestHandler> handler( | 93 scoped_ptr<ServiceWorkerContextRequestHandler> handler( |
94 new ServiceWorkerContextRequestHandler( | 94 new ServiceWorkerContextRequestHandler( |
95 context()->AsWeakPtr(), | 95 context()->AsWeakPtr(), |
96 provider_host_, | 96 provider_host_, |
97 base::WeakPtr<storage::BlobStorageContext>(), | 97 base::WeakPtr<storage::BlobStorageContext>(), |
98 RESOURCE_TYPE_SERVICE_WORKER)); | 98 RESOURCE_TYPE_SERVICE_WORKER)); |
99 scoped_refptr<net::URLRequestJob> job = | 99 scoped_refptr<net::URLRequestJob> job = |
100 handler->MaybeCreateJob(request.get(), NULL); | 100 handler->MaybeCreateJob(request.get(), NULL, NULL); |
101 ASSERT_TRUE(job.get()); | 101 ASSERT_TRUE(job.get()); |
102 ServiceWorkerWriteToCacheJob* sw_job = | 102 ServiceWorkerWriteToCacheJob* sw_job = |
103 static_cast<ServiceWorkerWriteToCacheJob*>(job.get()); | 103 static_cast<ServiceWorkerWriteToCacheJob*>(job.get()); |
104 | 104 |
105 // Verify the net request is not initialized to bypass the browser cache. | 105 // Verify the net request is not initialized to bypass the browser cache. |
106 EXPECT_FALSE(sw_job->net_request_->load_flags() & net::LOAD_BYPASS_CACHE); | 106 EXPECT_FALSE(sw_job->net_request_->load_flags() & net::LOAD_BYPASS_CACHE); |
107 } | 107 } |
108 | 108 |
109 TEST_F(ServiceWorkerContextRequestHandlerTest, UpdateAfter24Hours) { | 109 TEST_F(ServiceWorkerContextRequestHandlerTest, UpdateAfter24Hours) { |
110 // Give the registration a old update time and pretend | 110 // Give the registration a old update time and pretend |
(...skipping 10 matching lines...) Expand all Loading... |
121 net::DEFAULT_PRIORITY, | 121 net::DEFAULT_PRIORITY, |
122 &url_request_delegate_, | 122 &url_request_delegate_, |
123 NULL); | 123 NULL); |
124 scoped_ptr<ServiceWorkerContextRequestHandler> handler( | 124 scoped_ptr<ServiceWorkerContextRequestHandler> handler( |
125 new ServiceWorkerContextRequestHandler( | 125 new ServiceWorkerContextRequestHandler( |
126 context()->AsWeakPtr(), | 126 context()->AsWeakPtr(), |
127 provider_host_, | 127 provider_host_, |
128 base::WeakPtr<storage::BlobStorageContext>(), | 128 base::WeakPtr<storage::BlobStorageContext>(), |
129 RESOURCE_TYPE_SERVICE_WORKER)); | 129 RESOURCE_TYPE_SERVICE_WORKER)); |
130 scoped_refptr<net::URLRequestJob> job = | 130 scoped_refptr<net::URLRequestJob> job = |
131 handler->MaybeCreateJob(request.get(), NULL); | 131 handler->MaybeCreateJob(request.get(), NULL, NULL); |
132 ASSERT_TRUE(job.get()); | 132 ASSERT_TRUE(job.get()); |
133 ServiceWorkerWriteToCacheJob* sw_job = | 133 ServiceWorkerWriteToCacheJob* sw_job = |
134 static_cast<ServiceWorkerWriteToCacheJob*>(job.get()); | 134 static_cast<ServiceWorkerWriteToCacheJob*>(job.get()); |
135 | 135 |
136 // Verify the net request is initialized to bypass the browser cache. | 136 // Verify the net request is initialized to bypass the browser cache. |
137 EXPECT_TRUE(sw_job->net_request_->load_flags() & net::LOAD_BYPASS_CACHE); | 137 EXPECT_TRUE(sw_job->net_request_->load_flags() & net::LOAD_BYPASS_CACHE); |
138 } | 138 } |
139 | 139 |
140 } // namespace content | 140 } // namespace content |
OLD | NEW |