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

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

Issue 2422923002: Reduce usage of FOR_EACH_OBSERVER macro in content/browser (Closed)
Patch Set: skip cases in 2418143004 and 2418373002 Created 4 years, 2 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
« no previous file with comments | « content/browser/notification_service_impl.cc ('k') | content/browser/site_instance_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 it->second->RemoveRequestFromFrame(render_process_id, render_frame_id); 467 it->second->RemoveRequestFromFrame(render_process_id, render_frame_id);
468 if (it->second->requests()->empty()) 468 if (it->second->requests()->empty())
469 it = pending_instances_.erase(it); 469 it = pending_instances_.erase(it);
470 else 470 else
471 ++it; 471 ++it;
472 } 472 }
473 } 473 }
474 474
475 void SharedWorkerServiceImpl::NotifyWorkerDestroyed(int worker_process_id, 475 void SharedWorkerServiceImpl::NotifyWorkerDestroyed(int worker_process_id,
476 int worker_route_id) { 476 int worker_route_id) {
477 FOR_EACH_OBSERVER(WorkerServiceObserver, 477 for (auto& observer : observers_)
478 observers_, 478 observer.WorkerDestroyed(worker_process_id, worker_route_id);
479 WorkerDestroyed(worker_process_id, worker_route_id));
480 } 479 }
481 480
482 blink::WebWorkerCreationError 481 blink::WebWorkerCreationError
483 SharedWorkerServiceImpl::ReserveRenderProcessToCreateWorker( 482 SharedWorkerServiceImpl::ReserveRenderProcessToCreateWorker(
484 std::unique_ptr<SharedWorkerPendingInstance> pending_instance) { 483 std::unique_ptr<SharedWorkerPendingInstance> pending_instance) {
485 DCHECK_CURRENTLY_ON(BrowserThread::IO); 484 DCHECK_CURRENTLY_ON(BrowserThread::IO);
486 DCHECK(!FindPendingInstance(*pending_instance->instance())); 485 DCHECK(!FindPendingInstance(*pending_instance->instance()));
487 if (!pending_instance->requests()->size()) 486 if (!pending_instance->requests()->size())
488 return blink::WebWorkerCreationErrorNone; 487 return blink::WebWorkerCreationErrorNone;
489 488
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 } 585 }
587 586
588 std::unique_ptr<SharedWorkerHost> host(new SharedWorkerHost( 587 std::unique_ptr<SharedWorkerHost> host(new SharedWorkerHost(
589 pending_instance->release_instance(), filter, worker_route_id)); 588 pending_instance->release_instance(), filter, worker_route_id));
590 pending_instance->RegisterToSharedWorkerHost(host.get()); 589 pending_instance->RegisterToSharedWorkerHost(host.get());
591 const GURL url = host->instance()->url(); 590 const GURL url = host->instance()->url();
592 const base::string16 name = host->instance()->name(); 591 const base::string16 name = host->instance()->name();
593 host->Start(pause_on_start); 592 host->Start(pause_on_start);
594 ProcessRouteIdPair key(worker_process_id, worker_route_id); 593 ProcessRouteIdPair key(worker_process_id, worker_route_id);
595 worker_hosts_[key] = std::move(host); 594 worker_hosts_[key] = std::move(host);
596 FOR_EACH_OBSERVER( 595 for (auto& observer : observers_)
597 WorkerServiceObserver, 596 observer.WorkerCreated(url, name, worker_process_id, worker_route_id);
598 observers_,
599 WorkerCreated(url, name, worker_process_id, worker_route_id));
600 } 597 }
601 598
602 void SharedWorkerServiceImpl::RenderProcessReserveFailedCallback( 599 void SharedWorkerServiceImpl::RenderProcessReserveFailedCallback(
603 int pending_instance_id, 600 int pending_instance_id,
604 int worker_process_id, 601 int worker_process_id,
605 int worker_route_id, 602 int worker_route_id,
606 bool is_new_worker) { 603 bool is_new_worker) {
607 worker_hosts_.erase(std::make_pair(worker_process_id, worker_route_id)); 604 worker_hosts_.erase(std::make_pair(worker_process_id, worker_route_id));
608 if (!base::ContainsKey(pending_instances_, pending_instance_id)) 605 if (!base::ContainsKey(pending_instances_, pending_instance_id))
609 return; 606 return;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 UpdateWorkerDependencyFunc new_func) { 676 UpdateWorkerDependencyFunc new_func) {
680 update_worker_dependency_ = new_func; 677 update_worker_dependency_ = new_func;
681 } 678 }
682 679
683 void SharedWorkerServiceImpl::ChangeTryIncrementWorkerRefCountFuncForTesting( 680 void SharedWorkerServiceImpl::ChangeTryIncrementWorkerRefCountFuncForTesting(
684 bool (*new_func)(int)) { 681 bool (*new_func)(int)) {
685 s_try_increment_worker_ref_count_ = new_func; 682 s_try_increment_worker_ref_count_ = new_func;
686 } 683 }
687 684
688 } // namespace content 685 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/notification_service_impl.cc ('k') | content/browser/site_instance_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698