| 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.h" | 7 #include "content/child/child_thread.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/render_view_impl.h" | 10 #include "content/renderer/render_view_impl.h" |
| 11 #include "content/renderer/websharedworker_proxy.h" | 11 #include "content/renderer/websharedworker_proxy.h" |
| 12 #include "third_party/WebKit/public/web/WebFrame.h" | 12 #include "third_party/WebKit/public/web/WebFrame.h" |
| 13 | 13 |
| 14 namespace content { | 14 namespace content { |
| 15 | 15 |
| 16 SharedWorkerRepository::SharedWorkerRepository(RenderFrameImpl* render_frame) | 16 SharedWorkerRepository::SharedWorkerRepository(RenderFrameImpl* render_frame) |
| 17 : RenderFrameObserver(render_frame) { | 17 : RenderFrameObserver(render_frame) { |
| 18 } | 18 } |
| 19 | 19 |
| 20 SharedWorkerRepository::~SharedWorkerRepository() {} | 20 SharedWorkerRepository::~SharedWorkerRepository() {} |
| 21 | 21 |
| 22 void SharedWorkerRepository::WebFrameCreated(blink::WebFrame* frame) { | 22 void SharedWorkerRepository::WebFrameCreated(blink::WebFrame* frame) { |
| 23 frame->setSharedWorkerRepositoryClient(this); | 23 frame->setSharedWorkerRepositoryClient(this); |
| 24 } | 24 } |
| 25 | 25 |
| 26 blink::WebSharedWorkerConnector* | 26 blink::WebSharedWorkerConnector* |
| 27 SharedWorkerRepository::createSharedWorkerConnector( | 27 SharedWorkerRepository::createSharedWorkerConnector( |
| 28 const blink::WebURL& url, | 28 const blink::WebURL& url, |
| 29 const blink::WebString& name, | 29 const blink::WebString& name, |
| 30 DocumentID document_id) { | 30 DocumentID document_id, |
| 31 const blink::WebString& content_security_policy, |
| 32 blink::WebContentSecurityPolicyType security_policy_type) { |
| 31 int route_id = MSG_ROUTING_NONE; | 33 int route_id = MSG_ROUTING_NONE; |
| 32 bool exists = false; | 34 bool exists = false; |
| 33 bool url_mismatch = false; | 35 bool url_mismatch = false; |
| 34 ViewHostMsg_CreateWorker_Params params; | 36 ViewHostMsg_CreateWorker_Params params; |
| 35 params.url = url; | 37 params.url = url; |
| 36 params.name = name; | 38 params.name = name; |
| 39 params.content_security_policy = content_security_policy; |
| 40 params.security_policy_type = security_policy_type; |
| 37 params.document_id = document_id; | 41 params.document_id = document_id; |
| 38 params.render_view_route_id = render_frame()->GetRenderView()->GetRoutingID(); | 42 params.render_view_route_id = render_frame()->GetRenderView()->GetRoutingID(); |
| 39 params.render_frame_route_id = render_frame()->GetRoutingID(); | 43 params.render_frame_route_id = render_frame()->GetRoutingID(); |
| 40 params.route_id = MSG_ROUTING_NONE; | 44 params.route_id = MSG_ROUTING_NONE; |
| 41 params.script_resource_appcache_id = 0; | 45 params.script_resource_appcache_id = 0; |
| 42 Send(new ViewHostMsg_LookupSharedWorker( | 46 Send(new ViewHostMsg_LookupSharedWorker( |
| 43 params, &exists, &route_id, &url_mismatch)); | 47 params, &exists, &route_id, &url_mismatch)); |
| 44 if (url_mismatch) | 48 if (url_mismatch) |
| 45 return NULL; | 49 return NULL; |
| 46 documents_with_workers_.insert(document_id); | 50 documents_with_workers_.insert(document_id); |
| 47 return new WebSharedWorkerProxy(ChildThread::current(), | 51 return new WebSharedWorkerProxy(ChildThread::current(), |
| 48 document_id, | 52 document_id, |
| 49 exists, | 53 exists, |
| 50 route_id, | 54 route_id, |
| 51 params.render_view_route_id, | 55 params.render_view_route_id, |
| 52 params.render_frame_route_id); | 56 params.render_frame_route_id); |
| 53 } | 57 } |
| 54 | 58 |
| 55 void SharedWorkerRepository::documentDetached(DocumentID document) { | 59 void SharedWorkerRepository::documentDetached(DocumentID document) { |
| 56 std::set<DocumentID>::iterator iter = documents_with_workers_.find(document); | 60 std::set<DocumentID>::iterator iter = documents_with_workers_.find(document); |
| 57 if (iter != documents_with_workers_.end()) { | 61 if (iter != documents_with_workers_.end()) { |
| 58 // Notify the browser process that the document has shut down. | 62 // Notify the browser process that the document has shut down. |
| 59 Send(new ViewHostMsg_DocumentDetached(document)); | 63 Send(new ViewHostMsg_DocumentDetached(document)); |
| 60 documents_with_workers_.erase(iter); | 64 documents_with_workers_.erase(iter); |
| 61 } | 65 } |
| 62 } | 66 } |
| 63 | 67 |
| 64 } // namespace content | 68 } // namespace content |
| OLD | NEW |