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 "content/child/service_worker/service_worker_network_provider.h" | 5 #include "content/child/service_worker/service_worker_network_provider.h" |
6 | 6 |
7 #include "base/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
8 #include "content/child/child_thread_impl.h" | 8 #include "content/child/child_thread_impl.h" |
9 #include "content/child/service_worker/service_worker_provider_context.h" | 9 #include "content/child/service_worker/service_worker_provider_context.h" |
10 #include "content/common/service_worker/service_worker_messages.h" | 10 #include "content/common/service_worker/service_worker_messages.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 datasource_userdata->SetUserData(&kUserDataKey, network_provider.release()); | 29 datasource_userdata->SetUserData(&kUserDataKey, network_provider.release()); |
30 } | 30 } |
31 | 31 |
32 ServiceWorkerNetworkProvider* ServiceWorkerNetworkProvider::FromDocumentState( | 32 ServiceWorkerNetworkProvider* ServiceWorkerNetworkProvider::FromDocumentState( |
33 base::SupportsUserData* datasource_userdata) { | 33 base::SupportsUserData* datasource_userdata) { |
34 return static_cast<ServiceWorkerNetworkProvider*>( | 34 return static_cast<ServiceWorkerNetworkProvider*>( |
35 datasource_userdata->GetUserData(&kUserDataKey)); | 35 datasource_userdata->GetUserData(&kUserDataKey)); |
36 } | 36 } |
37 | 37 |
38 ServiceWorkerNetworkProvider::ServiceWorkerNetworkProvider( | 38 ServiceWorkerNetworkProvider::ServiceWorkerNetworkProvider( |
39 int render_frame_id, | 39 int route_id, |
40 ServiceWorkerProviderType provider_type) | 40 ServiceWorkerProviderType provider_type) |
41 : provider_id_(GetNextProviderId()), | 41 : provider_id_(GetNextProviderId()), |
42 context_(new ServiceWorkerProviderContext(provider_id_)) { | 42 context_(new ServiceWorkerProviderContext(provider_id_)) { |
43 if (!ChildThreadImpl::current()) | 43 if (!ChildThreadImpl::current()) |
44 return; // May be null in some tests. | 44 return; // May be null in some tests. |
45 ChildThreadImpl::current()->Send( | 45 ChildThreadImpl::current()->Send(new ServiceWorkerHostMsg_ProviderCreated( |
46 new ServiceWorkerHostMsg_ProviderCreated( | 46 provider_id_, route_id, provider_type)); |
47 provider_id_, render_frame_id, provider_type)); | |
48 } | 47 } |
49 | 48 |
50 ServiceWorkerNetworkProvider::~ServiceWorkerNetworkProvider() { | 49 ServiceWorkerNetworkProvider::~ServiceWorkerNetworkProvider() { |
51 if (!ChildThreadImpl::current()) | 50 if (!ChildThreadImpl::current()) |
52 return; // May be null in some tests. | 51 return; // May be null in some tests. |
53 ChildThreadImpl::current()->Send( | 52 ChildThreadImpl::current()->Send( |
54 new ServiceWorkerHostMsg_ProviderDestroyed(provider_id_)); | 53 new ServiceWorkerHostMsg_ProviderDestroyed(provider_id_)); |
55 } | 54 } |
56 | 55 |
57 void ServiceWorkerNetworkProvider::SetServiceWorkerVersionId( | 56 void ServiceWorkerNetworkProvider::SetServiceWorkerVersionId( |
58 int64 version_id) { | 57 int64 version_id) { |
59 if (!ChildThreadImpl::current()) | 58 if (!ChildThreadImpl::current()) |
60 return; // May be null in some tests. | 59 return; // May be null in some tests. |
61 ChildThreadImpl::current()->Send( | 60 ChildThreadImpl::current()->Send( |
62 new ServiceWorkerHostMsg_SetVersionId(provider_id_, version_id)); | 61 new ServiceWorkerHostMsg_SetVersionId(provider_id_, version_id)); |
63 } | 62 } |
64 | 63 |
65 } // namespace content | 64 } // namespace content |
OLD | NEW |