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 "ipc/ipc_sync_channel.h" | |
11 | 12 |
12 namespace content { | 13 namespace content { |
13 | 14 |
14 SharedWorkerRepository::SharedWorkerRepository(RenderFrameImpl* render_frame) | 15 SharedWorkerRepository::SharedWorkerRepository(RenderFrameImpl* render_frame) |
15 : render_frame_(render_frame){}; | 16 : render_frame_(render_frame) { |
17 if (!ChildThreadImpl::current()) | |
18 return; // May be null in some tests. | |
19 ChildThreadImpl::current()->channel()->GetRemoteAssociatedInterface( | |
20 &message_filter_); | |
21 } | |
16 | 22 |
17 SharedWorkerRepository::~SharedWorkerRepository() = default; | 23 SharedWorkerRepository::~SharedWorkerRepository() = default; |
18 | 24 |
19 std::unique_ptr<blink::WebSharedWorkerConnector> | 25 std::unique_ptr<blink::WebSharedWorkerConnector> |
20 SharedWorkerRepository::createSharedWorkerConnector( | 26 SharedWorkerRepository::createSharedWorkerConnector( |
21 const blink::WebURL& url, | 27 const blink::WebURL& url, |
22 const blink::WebString& name, | 28 const blink::WebString& name, |
23 DocumentID document_id, | 29 DocumentID document_id, |
24 const blink::WebString& content_security_policy, | 30 const blink::WebString& content_security_policy, |
25 blink::WebContentSecurityPolicyType security_policy_type, | 31 blink::WebContentSecurityPolicyType security_policy_type, |
26 blink::WebAddressSpace creation_address_space, | 32 blink::WebAddressSpace creation_address_space, |
27 blink::WebSharedWorkerCreationContextType creation_context_type, | 33 blink::WebSharedWorkerCreationContextType creation_context_type, |
28 blink::WebWorkerCreationError* error) { | 34 blink::WebWorkerCreationError* error) { |
29 ViewHostMsg_CreateWorker_Params params; | 35 mojom::SharedWorker_CreateWorker_ParamsPtr params = |
30 params.url = url; | 36 mojom::SharedWorker_CreateWorker_Params::New(); |
31 params.name = name.utf16(); | 37 params->url = url; |
32 params.content_security_policy = content_security_policy.utf16(); | 38 params->name = name.utf16(); |
33 params.security_policy_type = security_policy_type; | 39 params->content_security_policy = content_security_policy.utf16(); |
34 params.document_id = document_id; | 40 params->security_policy_type = |
35 params.render_frame_route_id = render_frame_->GetRoutingID(); | 41 static_cast<mojom::WebContentSecurityPolicyType>(security_policy_type); |
nhiroki
2016/12/28 09:24:30
I plan to add enum traits or replace blink::Enum w
nhiroki
2017/01/10 08:44:06
Added typemap in this CL.
| |
36 params.creation_address_space = creation_address_space; | 42 params->document_id = document_id; |
37 params.creation_context_type = creation_context_type; | 43 params->render_frame_route_id = render_frame_->GetRoutingID(); |
38 ViewHostMsg_CreateWorker_Reply reply; | 44 params->creation_address_space = |
39 render_frame_->Send(new ViewHostMsg_CreateWorker(params, &reply)); | 45 static_cast<mojom::WebAddressSpace>(creation_address_space); |
40 *error = reply.error; | 46 params->creation_context_type = |
47 static_cast<mojom::WebSharedWorkerCreationContextType>( | |
48 creation_context_type); | |
49 | |
50 mojom::SharedWorker_CreateWorker_ReplyPtr reply; | |
51 message_filter_->OnCreateWorker(std::move(params), &reply); | |
52 *error = static_cast<blink::WebWorkerCreationError>(reply->error); | |
41 documents_with_workers_.insert(document_id); | 53 documents_with_workers_.insert(document_id); |
42 return base::MakeUnique<WebSharedWorkerProxy>( | 54 |
43 ChildThreadImpl::current()->GetRouter(), reply.route_id); | 55 return base::MakeUnique<WebSharedWorkerProxy>(reply->route_id); |
44 } | 56 } |
45 | 57 |
46 void SharedWorkerRepository::documentDetached(DocumentID document) { | 58 void SharedWorkerRepository::documentDetached(DocumentID document) { |
47 std::set<DocumentID>::iterator iter = documents_with_workers_.find(document); | 59 std::set<DocumentID>::iterator iter = documents_with_workers_.find(document); |
48 if (iter != documents_with_workers_.end()) { | 60 if (iter != documents_with_workers_.end()) { |
49 // Notify the browser process that the document has shut down. | 61 // Notify the browser process that the document has shut down. |
50 render_frame_->Send(new ViewHostMsg_DocumentDetached(document)); | 62 message_filter_->OnDocumentDetached(document); |
51 documents_with_workers_.erase(iter); | 63 documents_with_workers_.erase(iter); |
52 } | 64 } |
53 } | 65 } |
54 | 66 |
55 } // namespace content | 67 } // namespace content |
OLD | NEW |