| 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/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/callback.h" | 6 #include "base/callback.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 124 |
| 125 void SetUpWithHelper(EmbeddedWorkerTestHelper* helper, | 125 void SetUpWithHelper(EmbeddedWorkerTestHelper* helper, |
| 126 bool set_main_script_http_response_info = true) { | 126 bool set_main_script_http_response_info = true) { |
| 127 helper_.reset(helper); | 127 helper_.reset(helper); |
| 128 | 128 |
| 129 registration_ = new ServiceWorkerRegistration( | 129 registration_ = new ServiceWorkerRegistration( |
| 130 GURL("http://example.com/"), | 130 GURL("http://example.com/"), |
| 131 1L, | 131 1L, |
| 132 helper_->context()->AsWeakPtr()); | 132 helper_->context()->AsWeakPtr()); |
| 133 version_ = new ServiceWorkerVersion( | 133 version_ = new ServiceWorkerVersion( |
| 134 registration_.get(), | 134 registration_.get(), GURL("http://example.com/service_worker.js"), |
| 135 GURL("http://example.com/service_worker.js"), | 135 std::string("3753e33b-532e-4499-92b8-96ea1d343fe5"), |
| 136 1L, | |
| 137 helper_->context()->AsWeakPtr()); | 136 helper_->context()->AsWeakPtr()); |
| 138 std::vector<ServiceWorkerDatabase::ResourceRecord> records; | 137 std::vector<ServiceWorkerDatabase::ResourceRecord> records; |
| 139 records.push_back( | 138 records.push_back( |
| 140 ServiceWorkerDatabase::ResourceRecord(10, version_->script_url(), 100)); | 139 ServiceWorkerDatabase::ResourceRecord(10, version_->script_url(), 100)); |
| 141 version_->script_cache_map()->SetResources(records); | 140 version_->script_cache_map()->SetResources(records); |
| 142 | 141 |
| 143 // Make the registration findable via storage functions. | 142 // Make the registration findable via storage functions. |
| 144 helper_->context()->storage()->LazyInitialize(base::Bind(&base::DoNothing)); | 143 helper_->context()->storage()->LazyInitialize(base::Bind(&base::DoNothing)); |
| 145 base::RunLoop().RunUntilIdle(); | 144 base::RunLoop().RunUntilIdle(); |
| 146 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; | 145 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 base::RunLoop().RunUntilIdle(); | 659 base::RunLoop().RunUntilIdle(); |
| 661 EXPECT_TRUE(request_->status().is_success()); | 660 EXPECT_TRUE(request_->status().is_success()); |
| 662 EXPECT_EQ(200, request_->GetResponseCode()); | 661 EXPECT_EQ(200, request_->GetResponseCode()); |
| 663 EXPECT_EQ("", url_request_delegate_.response_data()); | 662 EXPECT_EQ("", url_request_delegate_.response_data()); |
| 664 } | 663 } |
| 665 | 664 |
| 666 // TODO(kinuko): Add more tests with different response data and also for | 665 // TODO(kinuko): Add more tests with different response data and also for |
| 667 // FallbackToNetwork case. | 666 // FallbackToNetwork case. |
| 668 | 667 |
| 669 } // namespace content | 668 } // namespace content |
| OLD | NEW |