| 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 <stdint.h> | 7 #include <stdint.h> | 
| 8 | 8 | 
| 9 #include <utility> | 9 #include <utility> | 
| 10 | 10 | 
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 122 | 122 | 
| 123   void SetUpRegistration(const GURL& scope, const GURL& script_url) { | 123   void SetUpRegistration(const GURL& scope, const GURL& script_url) { | 
| 124     registration_ = new ServiceWorkerRegistration( | 124     registration_ = new ServiceWorkerRegistration( | 
| 125         scope, 1L, helper_->context()->AsWeakPtr()); | 125         scope, 1L, helper_->context()->AsWeakPtr()); | 
| 126     version_ = new ServiceWorkerVersion(registration_.get(), script_url, 1L, | 126     version_ = new ServiceWorkerVersion(registration_.get(), script_url, 1L, | 
| 127                                         helper_->context()->AsWeakPtr()); | 127                                         helper_->context()->AsWeakPtr()); | 
| 128     std::vector<ServiceWorkerDatabase::ResourceRecord> records; | 128     std::vector<ServiceWorkerDatabase::ResourceRecord> records; | 
| 129     records.push_back( | 129     records.push_back( | 
| 130         ServiceWorkerDatabase::ResourceRecord(10, version_->script_url(), 100)); | 130         ServiceWorkerDatabase::ResourceRecord(10, version_->script_url(), 100)); | 
| 131     version_->script_cache_map()->SetResources(records); | 131     version_->script_cache_map()->SetResources(records); | 
|  | 132     version_->set_fetch_handler_existence( | 
|  | 133         ServiceWorkerVersion::FetchHandlerExistence::EXISTS); | 
|  | 134     version_->SetStatus(ServiceWorkerVersion::INSTALLING); | 
| 132 | 135 | 
| 133     // Make the registration findable via storage functions. | 136     // Make the registration findable via storage functions. | 
| 134     helper_->context()->storage()->LazyInitialize(base::Bind(&base::DoNothing)); | 137     helper_->context()->storage()->LazyInitialize(base::Bind(&base::DoNothing)); | 
| 135     base::RunLoop().RunUntilIdle(); | 138     base::RunLoop().RunUntilIdle(); | 
| 136     bool called = false; | 139     bool called = false; | 
| 137     ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_MAX_VALUE; | 140     ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_MAX_VALUE; | 
| 138     helper_->context()->storage()->StoreRegistration( | 141     helper_->context()->storage()->StoreRegistration( | 
| 139         registration_.get(), version_.get(), | 142         registration_.get(), version_.get(), | 
| 140         base::Bind(&SaveStatusCallback, &called, &status)); | 143         base::Bind(&SaveStatusCallback, &called, &status)); | 
| 141     base::RunLoop().RunUntilIdle(); | 144     base::RunLoop().RunUntilIdle(); | 
| (...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 823   const int kRequestId = 91;  // Dummy value | 826   const int kRequestId = 91;  // Dummy value | 
| 824   dispatcher_host_->OnMessageReceived(ServiceWorkerHostMsg_FetchEventResponse( | 827   dispatcher_host_->OnMessageReceived(ServiceWorkerHostMsg_FetchEventResponse( | 
| 825       version_->embedded_worker()->embedded_worker_id(), kRequestId, | 828       version_->embedded_worker()->embedded_worker_id(), kRequestId, | 
| 826       SERVICE_WORKER_FETCH_EVENT_RESULT_FALLBACK, ServiceWorkerResponse())); | 829       SERVICE_WORKER_FETCH_EVENT_RESULT_FALLBACK, ServiceWorkerResponse())); | 
| 827 | 830 | 
| 828   base::RunLoop().RunUntilIdle(); | 831   base::RunLoop().RunUntilIdle(); | 
| 829   EXPECT_EQ(0, dispatcher_host_->bad_messages_received_count_); | 832   EXPECT_EQ(0, dispatcher_host_->bad_messages_received_count_); | 
| 830 } | 833 } | 
| 831 | 834 | 
| 832 }  // namespace content | 835 }  // namespace content | 
| OLD | NEW | 
|---|