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

Side by Side Diff: content/browser/shared_worker/shared_worker_service_impl.cc

Issue 2422793002: HTML MessagePort as mojo::MessagePipeHandle (Closed)
Patch Set: Add comments about threading in message_port.h Created 3 years, 10 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/browser/shared_worker/shared_worker_service_impl.h" 5 #include "content/browser/shared_worker/shared_worker_service_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <iterator> 10 #include <iterator>
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 return blink::WebWorkerCreationErrorNone; 318 return blink::WebWorkerCreationErrorNone;
319 } 319 }
320 320
321 std::unique_ptr<SharedWorkerPendingInstance> pending_instance( 321 std::unique_ptr<SharedWorkerPendingInstance> pending_instance(
322 new SharedWorkerPendingInstance(std::move(instance))); 322 new SharedWorkerPendingInstance(std::move(instance)));
323 pending_instance->AddRequest(std::move(request)); 323 pending_instance->AddRequest(std::move(request));
324 return ReserveRenderProcessToCreateWorker(std::move(pending_instance)); 324 return ReserveRenderProcessToCreateWorker(std::move(pending_instance));
325 } 325 }
326 326
327 void SharedWorkerServiceImpl::ConnectToWorker(SharedWorkerMessageFilter* filter, 327 void SharedWorkerServiceImpl::ConnectToWorker(SharedWorkerMessageFilter* filter,
328 int route_id, 328 int worker_route_id,
329 int sent_message_port_id) { 329 const MessagePort& port) {
330 for (WorkerHostMap::const_iterator iter = worker_hosts_.begin(); 330 for (WorkerHostMap::const_iterator iter = worker_hosts_.begin();
331 iter != worker_hosts_.end(); 331 iter != worker_hosts_.end();
332 ++iter) { 332 ++iter) {
333 if (iter->second->FilterConnectionMessage(route_id, sent_message_port_id, 333 if (iter->second->SendConnectToWorker(worker_route_id, port, filter))
334 filter))
335 return; 334 return;
336 } 335 }
337 } 336 }
338 337
339 void SharedWorkerServiceImpl::DocumentDetached( 338 void SharedWorkerServiceImpl::DocumentDetached(
340 SharedWorkerMessageFilter* filter, 339 SharedWorkerMessageFilter* filter,
341 unsigned long long document_id) { 340 unsigned long long document_id) {
342 ScopedWorkerDependencyChecker checker(this); 341 ScopedWorkerDependencyChecker checker(this);
343 for (WorkerHostMap::const_iterator iter = worker_hosts_.begin(); 342 for (WorkerHostMap::const_iterator iter = worker_hosts_.begin();
344 iter != worker_hosts_.end(); 343 iter != worker_hosts_.end();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 ScopedWorkerDependencyChecker checker(this); 398 ScopedWorkerDependencyChecker checker(this);
400 ProcessRouteIdPair key(filter->render_process_id(), worker_route_id); 399 ProcessRouteIdPair key(filter->render_process_id(), worker_route_id);
401 if (!base::ContainsKey(worker_hosts_, key)) 400 if (!base::ContainsKey(worker_hosts_, key))
402 return; 401 return;
403 std::unique_ptr<SharedWorkerHost> host(worker_hosts_[key].release()); 402 std::unique_ptr<SharedWorkerHost> host(worker_hosts_[key].release());
404 worker_hosts_.erase(key); 403 worker_hosts_.erase(key);
405 host->WorkerScriptLoadFailed(); 404 host->WorkerScriptLoadFailed();
406 } 405 }
407 406
408 void SharedWorkerServiceImpl::WorkerConnected(SharedWorkerMessageFilter* filter, 407 void SharedWorkerServiceImpl::WorkerConnected(SharedWorkerMessageFilter* filter,
409 int message_port_id, 408 int connection_request_id,
410 int worker_route_id) { 409 int worker_route_id) {
411 if (SharedWorkerHost* host = 410 if (SharedWorkerHost* host =
412 FindSharedWorkerHost(filter->render_process_id(), worker_route_id)) 411 FindSharedWorkerHost(filter->render_process_id(), worker_route_id))
413 host->WorkerConnected(message_port_id); 412 host->WorkerConnected(connection_request_id);
414 } 413 }
415 414
416 void SharedWorkerServiceImpl::AllowFileSystem(SharedWorkerMessageFilter* filter, 415 void SharedWorkerServiceImpl::AllowFileSystem(SharedWorkerMessageFilter* filter,
417 int worker_route_id, 416 int worker_route_id,
418 const GURL& url, 417 const GURL& url,
419 IPC::Message* reply_msg) { 418 IPC::Message* reply_msg) {
420 if (SharedWorkerHost* host = 419 if (SharedWorkerHost* host =
421 FindSharedWorkerHost(filter->render_process_id(), worker_route_id)) { 420 FindSharedWorkerHost(filter->render_process_id(), worker_route_id)) {
422 host->AllowFileSystem(url, base::WrapUnique(reply_msg)); 421 host->AllowFileSystem(url, base::WrapUnique(reply_msg));
423 } else { 422 } else {
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 UpdateWorkerDependencyFunc new_func) { 678 UpdateWorkerDependencyFunc new_func) {
680 update_worker_dependency_ = new_func; 679 update_worker_dependency_ = new_func;
681 } 680 }
682 681
683 void SharedWorkerServiceImpl::ChangeTryIncrementWorkerRefCountFuncForTesting( 682 void SharedWorkerServiceImpl::ChangeTryIncrementWorkerRefCountFuncForTesting(
684 bool (*new_func)(int)) { 683 bool (*new_func)(int)) {
685 s_try_increment_worker_ref_count_ = new_func; 684 s_try_increment_worker_ref_count_ = new_func;
686 } 685 }
687 686
688 } // namespace content 687 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698