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 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 // Add a provider and worker. | 494 // Add a provider and worker. |
495 const int64 kProviderId = 99; // Dummy value | 495 const int64 kProviderId = 99; // Dummy value |
496 dispatcher_host_->OnMessageReceived(ServiceWorkerHostMsg_ProviderCreated( | 496 dispatcher_host_->OnMessageReceived(ServiceWorkerHostMsg_ProviderCreated( |
497 kProviderId, MSG_ROUTING_NONE, SERVICE_WORKER_PROVIDER_FOR_WINDOW)); | 497 kProviderId, MSG_ROUTING_NONE, SERVICE_WORKER_PROVIDER_FOR_WINDOW)); |
498 | 498 |
499 GURL pattern = GURL("http://www.example.com/"); | 499 GURL pattern = GURL("http://www.example.com/"); |
500 scoped_refptr<ServiceWorkerRegistration> registration( | 500 scoped_refptr<ServiceWorkerRegistration> registration( |
501 new ServiceWorkerRegistration(pattern, | 501 new ServiceWorkerRegistration(pattern, |
502 1L, | 502 1L, |
503 helper_->context()->AsWeakPtr())); | 503 helper_->context()->AsWeakPtr())); |
504 scoped_refptr<ServiceWorkerVersion> version( | 504 scoped_refptr<ServiceWorkerVersion> version(new ServiceWorkerVersion( |
505 new ServiceWorkerVersion(registration.get(), | 505 registration.get(), GURL("http://www.example.com/service_worker.js"), |
506 GURL("http://www.example.com/service_worker.js"), | 506 std::string("2d73e817-7136-4133-8d59-84105fe5417a"), |
507 1L, | 507 helper_->context()->AsWeakPtr())); |
508 helper_->context()->AsWeakPtr())); | |
509 std::vector<ServiceWorkerDatabase::ResourceRecord> records; | 508 std::vector<ServiceWorkerDatabase::ResourceRecord> records; |
510 records.push_back( | 509 records.push_back( |
511 ServiceWorkerDatabase::ResourceRecord(10, version->script_url(), 100)); | 510 ServiceWorkerDatabase::ResourceRecord(10, version->script_url(), 100)); |
512 version->script_cache_map()->SetResources(records); | 511 version->script_cache_map()->SetResources(records); |
513 | 512 |
514 // Make the registration findable via storage functions. | 513 // Make the registration findable via storage functions. |
515 helper_->context()->storage()->LazyInitialize(base::Bind(&base::DoNothing)); | 514 helper_->context()->storage()->LazyInitialize(base::Bind(&base::DoNothing)); |
516 base::RunLoop().RunUntilIdle(); | 515 base::RunLoop().RunUntilIdle(); |
517 bool called = false; | 516 bool called = false; |
518 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_ABORT; | 517 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_ABORT; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 | 554 |
556 // To show the new dispatcher can operate, simulate provider creation. Since | 555 // 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 | 556 // the old dispatcher cleaned up the old provider host, the new one won't |
558 // complain. | 557 // complain. |
559 new_dispatcher_host->OnMessageReceived(ServiceWorkerHostMsg_ProviderCreated( | 558 new_dispatcher_host->OnMessageReceived(ServiceWorkerHostMsg_ProviderCreated( |
560 kProviderId, MSG_ROUTING_NONE, SERVICE_WORKER_PROVIDER_FOR_WINDOW)); | 559 kProviderId, MSG_ROUTING_NONE, SERVICE_WORKER_PROVIDER_FOR_WINDOW)); |
561 EXPECT_EQ(0, new_dispatcher_host->bad_messages_received_count_); | 560 EXPECT_EQ(0, new_dispatcher_host->bad_messages_received_count_); |
562 } | 561 } |
563 | 562 |
564 } // namespace content | 563 } // namespace content |
OLD | NEW |