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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "content/browser/browser_thread_impl.h" | 10 #include "content/browser/browser_thread_impl.h" |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 GURL pattern = GURL("http://www.example.com/"); | 503 GURL pattern = GURL("http://www.example.com/"); |
504 scoped_refptr<ServiceWorkerRegistration> registration( | 504 scoped_refptr<ServiceWorkerRegistration> registration( |
505 new ServiceWorkerRegistration(pattern, | 505 new ServiceWorkerRegistration(pattern, |
506 1L, | 506 1L, |
507 helper_->context()->AsWeakPtr())); | 507 helper_->context()->AsWeakPtr())); |
508 scoped_refptr<ServiceWorkerVersion> version( | 508 scoped_refptr<ServiceWorkerVersion> version( |
509 new ServiceWorkerVersion(registration.get(), | 509 new ServiceWorkerVersion(registration.get(), |
510 GURL("http://www.example.com/service_worker.js"), | 510 GURL("http://www.example.com/service_worker.js"), |
511 1L, | 511 1L, |
512 helper_->context()->AsWeakPtr())); | 512 helper_->context()->AsWeakPtr())); |
| 513 std::vector<ServiceWorkerDatabase::ResourceRecord> records; |
| 514 records.push_back( |
| 515 ServiceWorkerDatabase::ResourceRecord(10, version->script_url(), 100)); |
| 516 version->script_cache_map()->SetResources(records); |
513 | 517 |
514 // Make the registration findable via storage functions. | 518 // Make the registration findable via storage functions. |
515 helper_->context()->storage()->LazyInitialize(base::Bind(&base::DoNothing)); | 519 helper_->context()->storage()->LazyInitialize(base::Bind(&base::DoNothing)); |
516 base::RunLoop().RunUntilIdle(); | 520 base::RunLoop().RunUntilIdle(); |
517 bool called = false; | 521 bool called = false; |
518 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_ABORT; | 522 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_ABORT; |
519 helper_->context()->storage()->StoreRegistration( | 523 helper_->context()->storage()->StoreRegistration( |
520 registration.get(), | 524 registration.get(), |
521 version.get(), | 525 version.get(), |
522 base::Bind(&SaveStatusCallback, &called, &status)); | 526 base::Bind(&SaveStatusCallback, &called, &status)); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 | 559 |
556 // To show the new dispatcher can operate, simulate provider creation. Since | 560 // To show the new dispatcher can operate, simulate provider creation. Since |
557 // the old dispatcher cleaned up the old provider host, the new one won't | 561 // the old dispatcher cleaned up the old provider host, the new one won't |
558 // complain. | 562 // complain. |
559 new_dispatcher_host->OnMessageReceived(ServiceWorkerHostMsg_ProviderCreated( | 563 new_dispatcher_host->OnMessageReceived(ServiceWorkerHostMsg_ProviderCreated( |
560 kProviderId, MSG_ROUTING_NONE, SERVICE_WORKER_PROVIDER_FOR_WINDOW)); | 564 kProviderId, MSG_ROUTING_NONE, SERVICE_WORKER_PROVIDER_FOR_WINDOW)); |
561 EXPECT_EQ(0, new_dispatcher_host->bad_messages_received_count_); | 565 EXPECT_EQ(0, new_dispatcher_host->bad_messages_received_count_); |
562 } | 566 } |
563 | 567 |
564 } // namespace content | 568 } // namespace content |
OLD | NEW |