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/renderer/shared_worker/shared_worker_repository.h" | 5 #include "content/renderer/shared_worker/shared_worker_repository.h" |
6 | 6 |
7 #include "content/common/view_messages.h" | 7 #include "content/common/view_messages.h" |
8 #include "content/renderer/render_frame_impl.h" | 8 #include "content/renderer/render_frame_impl.h" |
9 #include "content/renderer/shared_worker/websharedworker_proxy.h" | 9 #include "content/renderer/shared_worker/websharedworker_proxy.h" |
10 #include "third_party/WebKit/public/web/WebSharedWorkerConnectListener.h" | 10 #include "third_party/WebKit/public/web/WebSharedWorkerConnectListener.h" |
11 | 11 |
12 namespace content { | 12 namespace content { |
13 | 13 |
14 SharedWorkerRepository::SharedWorkerRepository(RenderFrameImpl* render_frame) | 14 SharedWorkerRepository::SharedWorkerRepository(RenderFrameImpl* render_frame) |
15 : render_frame_(render_frame){}; | 15 : render_frame_(render_frame){}; |
16 | 16 |
17 SharedWorkerRepository::~SharedWorkerRepository() = default; | 17 SharedWorkerRepository::~SharedWorkerRepository() = default; |
18 | 18 |
19 void SharedWorkerRepository::Connect( | 19 void SharedWorkerRepository::Connect( |
20 const blink::WebURL& url, | 20 const blink::WebURL& url, |
21 const blink::WebString& name, | 21 const blink::WebString& name, |
22 DocumentID document_id, | 22 DocumentID document_id, |
23 const blink::WebString& content_security_policy, | 23 const blink::WebString& content_security_policy, |
24 blink::WebContentSecurityPolicyType security_policy_type, | 24 blink::WebContentSecurityPolicyType security_policy_type, |
25 blink::WebAddressSpace creation_address_space, | 25 blink::WebAddressSpace creation_address_space, |
26 blink::WebSharedWorkerCreationContextType creation_context_type, | 26 blink::WebSharedWorkerCreationContextType creation_context_type, |
| 27 bool data_saver_enabled, |
27 std::unique_ptr<blink::WebMessagePortChannel> channel, | 28 std::unique_ptr<blink::WebMessagePortChannel> channel, |
28 std::unique_ptr<blink::WebSharedWorkerConnectListener> listener) { | 29 std::unique_ptr<blink::WebSharedWorkerConnectListener> listener) { |
29 documents_with_workers_.insert(document_id); | 30 documents_with_workers_.insert(document_id); |
30 | 31 |
31 ViewHostMsg_CreateWorker_Params params; | 32 ViewHostMsg_CreateWorker_Params params; |
32 params.url = url; | 33 params.url = url; |
33 params.name = name.Utf16(); | 34 params.name = name.Utf16(); |
34 params.content_security_policy = content_security_policy.Utf16(); | 35 params.content_security_policy = content_security_policy.Utf16(); |
35 params.security_policy_type = security_policy_type; | 36 params.security_policy_type = security_policy_type; |
36 params.document_id = document_id; | 37 params.document_id = document_id; |
37 params.render_frame_route_id = render_frame_->GetRoutingID(); | 38 params.render_frame_route_id = render_frame_->GetRoutingID(); |
38 params.creation_address_space = creation_address_space; | 39 params.creation_address_space = creation_address_space; |
39 params.creation_context_type = creation_context_type; | 40 params.creation_context_type = creation_context_type; |
| 41 params.data_saver_enabled = data_saver_enabled; |
40 ViewHostMsg_CreateWorker_Reply reply; | 42 ViewHostMsg_CreateWorker_Reply reply; |
41 | 43 |
42 // This proxy will self-destruct when a worker is destroyed. | 44 // This proxy will self-destruct when a worker is destroyed. |
43 new WebSharedWorkerProxy(std::move(listener), params, std::move(channel)); | 45 new WebSharedWorkerProxy(std::move(listener), params, std::move(channel)); |
44 } | 46 } |
45 | 47 |
46 void SharedWorkerRepository::DocumentDetached(DocumentID document) { | 48 void SharedWorkerRepository::DocumentDetached(DocumentID document) { |
47 std::set<DocumentID>::iterator iter = documents_with_workers_.find(document); | 49 std::set<DocumentID>::iterator iter = documents_with_workers_.find(document); |
48 if (iter != documents_with_workers_.end()) { | 50 if (iter != documents_with_workers_.end()) { |
49 // Notify the browser process that the document has shut down. | 51 // Notify the browser process that the document has shut down. |
50 render_frame_->Send(new ViewHostMsg_DocumentDetached(document)); | 52 render_frame_->Send(new ViewHostMsg_DocumentDetached(document)); |
51 documents_with_workers_.erase(iter); | 53 documents_with_workers_.erase(iter); |
52 } | 54 } |
53 } | 55 } |
54 | 56 |
55 } // namespace content | 57 } // namespace content |
OLD | NEW |