Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Side by Side Diff: content/renderer/shared_worker/shared_worker_repository.cc

Issue 2627123003: SharedWorker: Simplify connection sequence (Closed)
Patch Set: remove unnecessary forward declaration Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/child/child_thread_impl.h"
8 #include "content/common/view_messages.h" 7 #include "content/common/view_messages.h"
9 #include "content/renderer/render_frame_impl.h" 8 #include "content/renderer/render_frame_impl.h"
10 #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"
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 std::unique_ptr<blink::WebSharedWorkerConnector> 19 void SharedWorkerRepository::connect(
20 SharedWorkerRepository::createSharedWorkerConnector(
21 const blink::WebURL& url, 20 const blink::WebURL& url,
22 const blink::WebString& name, 21 const blink::WebString& name,
23 DocumentID document_id, 22 DocumentID document_id,
24 const blink::WebString& content_security_policy, 23 const blink::WebString& content_security_policy,
25 blink::WebContentSecurityPolicyType security_policy_type, 24 blink::WebContentSecurityPolicyType security_policy_type,
26 blink::WebAddressSpace creation_address_space, 25 blink::WebAddressSpace creation_address_space,
27 blink::WebSharedWorkerCreationContextType creation_context_type, 26 blink::WebSharedWorkerCreationContextType creation_context_type,
28 blink::WebWorkerCreationError* error) { 27 blink::WebMessagePortChannel* channel,
28 std::unique_ptr<blink::WebSharedWorkerConnectListener> listener) {
29 documents_with_workers_.insert(document_id);
30
29 ViewHostMsg_CreateWorker_Params params; 31 ViewHostMsg_CreateWorker_Params params;
30 params.url = url; 32 params.url = url;
31 params.name = name.utf16(); 33 params.name = name.utf16();
32 params.content_security_policy = content_security_policy.utf16(); 34 params.content_security_policy = content_security_policy.utf16();
33 params.security_policy_type = security_policy_type; 35 params.security_policy_type = security_policy_type;
34 params.document_id = document_id; 36 params.document_id = document_id;
35 params.render_frame_route_id = render_frame_->GetRoutingID(); 37 params.render_frame_route_id = render_frame_->GetRoutingID();
36 params.creation_address_space = creation_address_space; 38 params.creation_address_space = creation_address_space;
37 params.creation_context_type = creation_context_type; 39 params.creation_context_type = creation_context_type;
38 ViewHostMsg_CreateWorker_Reply reply; 40 ViewHostMsg_CreateWorker_Reply reply;
39 render_frame_->Send(new ViewHostMsg_CreateWorker(params, &reply)); 41
40 *error = reply.error; 42 // This proxy will self-destruct when a connection is established.
41 documents_with_workers_.insert(document_id); 43 new WebSharedWorkerProxy(std::move(listener), params, channel);
42 return base::MakeUnique<WebSharedWorkerProxy>(
43 ChildThreadImpl::current()->GetRouter(), reply.route_id);
44 } 44 }
45 45
46 void SharedWorkerRepository::documentDetached(DocumentID document) { 46 void SharedWorkerRepository::documentDetached(DocumentID document) {
47 std::set<DocumentID>::iterator iter = documents_with_workers_.find(document); 47 std::set<DocumentID>::iterator iter = documents_with_workers_.find(document);
48 if (iter != documents_with_workers_.end()) { 48 if (iter != documents_with_workers_.end()) {
49 // Notify the browser process that the document has shut down. 49 // Notify the browser process that the document has shut down.
50 render_frame_->Send(new ViewHostMsg_DocumentDetached(document)); 50 render_frame_->Send(new ViewHostMsg_DocumentDetached(document));
51 documents_with_workers_.erase(iter); 51 documents_with_workers_.erase(iter);
52 } 52 }
53 } 53 }
54 54
55 } // namespace content 55 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/shared_worker/shared_worker_repository.h ('k') | content/renderer/shared_worker/websharedworker_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698