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_repository.h" | 5 #include "content/renderer/shared_worker_repository.h" |
6 | 6 |
7 #include "content/child/child_thread_impl.h" | 7 #include "content/child/child_thread_impl.h" |
8 #include "content/common/view_messages.h" | 8 #include "content/common/view_messages.h" |
9 #include "content/renderer/render_frame_impl.h" | 9 #include "content/renderer/render_frame_impl.h" |
10 #include "content/renderer/websharedworker_proxy.h" | 10 #include "content/renderer/websharedworker_proxy.h" |
11 #include "third_party/WebKit/public/web/WebContentSecurityPolicy.h" | |
12 #include "third_party/WebKit/public/web/WebLocalFrame.h" | |
13 | 11 |
14 namespace content { | 12 namespace content { |
15 | 13 |
16 SharedWorkerRepository::SharedWorkerRepository(RenderFrameImpl* render_frame) | 14 SharedWorkerRepository::SharedWorkerRepository(RenderFrameImpl* render_frame) |
17 : RenderFrameObserver(render_frame) { | 15 : render_frame_(render_frame){}; |
18 render_frame->GetWebFrame()->setSharedWorkerRepositoryClient(this); | |
19 } | |
20 | 16 |
21 SharedWorkerRepository::~SharedWorkerRepository() {} | 17 SharedWorkerRepository::~SharedWorkerRepository() = default; |
22 | 18 |
23 std::unique_ptr<blink::WebSharedWorkerConnector> | 19 std::unique_ptr<blink::WebSharedWorkerConnector> |
24 SharedWorkerRepository::createSharedWorkerConnector( | 20 SharedWorkerRepository::createSharedWorkerConnector( |
25 const blink::WebURL& url, | 21 const blink::WebURL& url, |
26 const blink::WebString& name, | 22 const blink::WebString& name, |
27 DocumentID document_id, | 23 DocumentID document_id, |
28 const blink::WebString& content_security_policy, | 24 const blink::WebString& content_security_policy, |
29 blink::WebContentSecurityPolicyType security_policy_type, | 25 blink::WebContentSecurityPolicyType security_policy_type, |
30 blink::WebAddressSpace creation_address_space, | 26 blink::WebAddressSpace creation_address_space, |
31 blink::WebSharedWorkerCreationContextType creation_context_type, | 27 blink::WebSharedWorkerCreationContextType creation_context_type, |
32 blink::WebWorkerCreationError* error) { | 28 blink::WebWorkerCreationError* error) { |
33 ViewHostMsg_CreateWorker_Params params; | 29 ViewHostMsg_CreateWorker_Params params; |
34 params.url = url; | 30 params.url = url; |
35 params.name = name.utf16(); | 31 params.name = name.utf16(); |
36 params.content_security_policy = content_security_policy.utf16(); | 32 params.content_security_policy = content_security_policy.utf16(); |
37 params.security_policy_type = security_policy_type; | 33 params.security_policy_type = security_policy_type; |
38 params.document_id = document_id; | 34 params.document_id = document_id; |
39 params.render_frame_route_id = render_frame()->GetRoutingID(); | 35 params.render_frame_route_id = render_frame_->GetRoutingID(); |
40 params.creation_address_space = creation_address_space; | 36 params.creation_address_space = creation_address_space; |
41 params.creation_context_type = creation_context_type; | 37 params.creation_context_type = creation_context_type; |
42 ViewHostMsg_CreateWorker_Reply reply; | 38 ViewHostMsg_CreateWorker_Reply reply; |
43 Send(new ViewHostMsg_CreateWorker(params, &reply)); | 39 render_frame_->Send(new ViewHostMsg_CreateWorker(params, &reply)); |
44 *error = reply.error; | 40 *error = reply.error; |
45 documents_with_workers_.insert(document_id); | 41 documents_with_workers_.insert(document_id); |
46 return base::MakeUnique<WebSharedWorkerProxy>( | 42 return base::MakeUnique<WebSharedWorkerProxy>( |
47 ChildThreadImpl::current()->GetRouter(), reply.route_id); | 43 ChildThreadImpl::current()->GetRouter(), reply.route_id); |
48 } | 44 } |
49 | 45 |
50 void SharedWorkerRepository::documentDetached(DocumentID document) { | 46 void SharedWorkerRepository::documentDetached(DocumentID document) { |
51 std::set<DocumentID>::iterator iter = documents_with_workers_.find(document); | 47 std::set<DocumentID>::iterator iter = documents_with_workers_.find(document); |
52 if (iter != documents_with_workers_.end()) { | 48 if (iter != documents_with_workers_.end()) { |
53 // Notify the browser process that the document has shut down. | 49 // Notify the browser process that the document has shut down. |
54 Send(new ViewHostMsg_DocumentDetached(document)); | 50 render_frame_->Send(new ViewHostMsg_DocumentDetached(document)); |
55 documents_with_workers_.erase(iter); | 51 documents_with_workers_.erase(iter); |
56 } | 52 } |
57 } | 53 } |
58 | 54 |
59 void SharedWorkerRepository::OnDestruct() { | |
60 delete this; | |
61 } | |
62 | |
63 } // namespace content | 55 } // namespace content |
OLD | NEW |