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