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

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

Issue 2422793002: HTML MessagePort as mojo::MessagePipeHandle (Closed)
Patch Set: Eliminate unnecessary PostTask 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 ScopedWorkerDependencyChecker checker(this); 385 ScopedWorkerDependencyChecker checker(this);
387 ProcessRouteIdPair key(filter->render_process_id(), worker_route_id); 386 ProcessRouteIdPair key(filter->render_process_id(), worker_route_id);
388 if (!base::ContainsKey(worker_hosts_, key)) 387 if (!base::ContainsKey(worker_hosts_, key))
389 return; 388 return;
390 std::unique_ptr<SharedWorkerHost> host(worker_hosts_[key].release()); 389 std::unique_ptr<SharedWorkerHost> host(worker_hosts_[key].release());
391 worker_hosts_.erase(key); 390 worker_hosts_.erase(key);
392 host->WorkerScriptLoadFailed(); 391 host->WorkerScriptLoadFailed();
393 } 392 }
394 393
395 void SharedWorkerServiceImpl::WorkerConnected(SharedWorkerMessageFilter* filter, 394 void SharedWorkerServiceImpl::WorkerConnected(SharedWorkerMessageFilter* filter,
396 int message_port_id, 395 int connection_request_id,
397 int worker_route_id) { 396 int worker_route_id) {
398 if (SharedWorkerHost* host = 397 if (SharedWorkerHost* host =
399 FindSharedWorkerHost(filter->render_process_id(), worker_route_id)) 398 FindSharedWorkerHost(filter->render_process_id(), worker_route_id))
400 host->WorkerConnected(message_port_id); 399 host->WorkerConnected(connection_request_id);
401 } 400 }
402 401
403 void SharedWorkerServiceImpl::AllowFileSystem(SharedWorkerMessageFilter* filter, 402 void SharedWorkerServiceImpl::AllowFileSystem(SharedWorkerMessageFilter* filter,
404 int worker_route_id, 403 int worker_route_id,
405 const GURL& url, 404 const GURL& url,
406 IPC::Message* reply_msg) { 405 IPC::Message* reply_msg) {
407 if (SharedWorkerHost* host = 406 if (SharedWorkerHost* host =
408 FindSharedWorkerHost(filter->render_process_id(), worker_route_id)) { 407 FindSharedWorkerHost(filter->render_process_id(), worker_route_id)) {
409 host->AllowFileSystem(url, base::WrapUnique(reply_msg)); 408 host->AllowFileSystem(url, base::WrapUnique(reply_msg));
410 } else { 409 } else {
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 UpdateWorkerDependencyFunc new_func) { 665 UpdateWorkerDependencyFunc new_func) {
667 update_worker_dependency_ = new_func; 666 update_worker_dependency_ = new_func;
668 } 667 }
669 668
670 void SharedWorkerServiceImpl::ChangeTryIncrementWorkerRefCountFuncForTesting( 669 void SharedWorkerServiceImpl::ChangeTryIncrementWorkerRefCountFuncForTesting(
671 bool (*new_func)(int)) { 670 bool (*new_func)(int)) {
672 s_try_increment_worker_ref_count_ = new_func; 671 s_try_increment_worker_ref_count_ = new_func;
673 } 672 }
674 673
675 } // namespace content 674 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698