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

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

Issue 2312633002: For debugging, split worker ref count into service worker and shared worker counts (Closed)
Patch Set: size_t Created 4 years, 3 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 DISALLOW_COPY_AND_ASSIGN(ScopedWorkerDependencyChecker); 52 DISALLOW_COPY_AND_ASSIGN(ScopedWorkerDependencyChecker);
53 }; 53 };
54 54
55 void UpdateWorkerDependencyOnUI(const std::vector<int>& added_ids, 55 void UpdateWorkerDependencyOnUI(const std::vector<int>& added_ids,
56 const std::vector<int>& removed_ids) { 56 const std::vector<int>& removed_ids) {
57 for (int id : added_ids) { 57 for (int id : added_ids) {
58 RenderProcessHostImpl* render_process_host_impl = 58 RenderProcessHostImpl* render_process_host_impl =
59 static_cast<RenderProcessHostImpl*>(RenderProcessHost::FromID(id)); 59 static_cast<RenderProcessHostImpl*>(RenderProcessHost::FromID(id));
60 if (!render_process_host_impl) 60 if (!render_process_host_impl)
61 continue; 61 continue;
62 render_process_host_impl->IncrementWorkerRefCount(); 62 render_process_host_impl->IncrementSharedWorkerRefCount();
63 } 63 }
64 for (int id : removed_ids) { 64 for (int id : removed_ids) {
65 RenderProcessHostImpl* render_process_host_impl = 65 RenderProcessHostImpl* render_process_host_impl =
66 static_cast<RenderProcessHostImpl*>(RenderProcessHost::FromID(id)); 66 static_cast<RenderProcessHostImpl*>(RenderProcessHost::FromID(id));
67 if (!render_process_host_impl) 67 if (!render_process_host_impl)
68 continue; 68 continue;
69 render_process_host_impl->DecrementWorkerRefCount(); 69 render_process_host_impl->DecrementSharedWorkerRefCount();
70 } 70 }
71 } 71 }
72 72
73 void UpdateWorkerDependency(const std::vector<int>& added_ids, 73 void UpdateWorkerDependency(const std::vector<int>& added_ids,
74 const std::vector<int>& removed_ids) { 74 const std::vector<int>& removed_ids) {
75 BrowserThread::PostTask( 75 BrowserThread::PostTask(
76 BrowserThread::UI, 76 BrowserThread::UI,
77 FROM_HERE, 77 FROM_HERE,
78 base::Bind(&UpdateWorkerDependencyOnUI, added_ids, removed_ids)); 78 base::Bind(&UpdateWorkerDependencyOnUI, added_ids, removed_ids));
79 } 79 }
80 80
81 void DecrementWorkerRefCount(int process_id) { 81 void DecrementWorkerRefCount(int process_id) {
82 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { 82 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
83 BrowserThread::PostTask(BrowserThread::UI, 83 BrowserThread::PostTask(BrowserThread::UI,
84 FROM_HERE, 84 FROM_HERE,
85 base::Bind(&DecrementWorkerRefCount, process_id)); 85 base::Bind(&DecrementWorkerRefCount, process_id));
86 return; 86 return;
87 } 87 }
88 RenderProcessHostImpl* render_process_host_impl = 88 RenderProcessHostImpl* render_process_host_impl =
89 static_cast<RenderProcessHostImpl*>( 89 static_cast<RenderProcessHostImpl*>(
90 RenderProcessHost::FromID(process_id)); 90 RenderProcessHost::FromID(process_id));
91 if (render_process_host_impl) 91 if (render_process_host_impl)
92 render_process_host_impl->DecrementWorkerRefCount(); 92 render_process_host_impl->DecrementSharedWorkerRefCount();
93 } 93 }
94 94
95 bool TryIncrementWorkerRefCount(int worker_process_id) { 95 bool TryIncrementWorkerRefCount(int worker_process_id) {
96 RenderProcessHostImpl* render_process = static_cast<RenderProcessHostImpl*>( 96 RenderProcessHostImpl* render_process = static_cast<RenderProcessHostImpl*>(
97 RenderProcessHost::FromID(worker_process_id)); 97 RenderProcessHost::FromID(worker_process_id));
98 if (!render_process || render_process->FastShutdownStarted()) 98 if (!render_process || render_process->FastShutdownStarted())
99 return false; 99 return false;
100 render_process->IncrementWorkerRefCount(); 100 render_process->IncrementSharedWorkerRefCount();
101 return true; 101 return true;
102 } 102 }
103 103
104 } // namespace 104 } // namespace
105 105
106 class SharedWorkerServiceImpl::SharedWorkerPendingInstance { 106 class SharedWorkerServiceImpl::SharedWorkerPendingInstance {
107 public: 107 public:
108 struct SharedWorkerPendingRequest { 108 struct SharedWorkerPendingRequest {
109 SharedWorkerPendingRequest(SharedWorkerMessageFilter* filter, 109 SharedWorkerPendingRequest(SharedWorkerMessageFilter* filter,
110 int route_id, 110 int route_id,
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 UpdateWorkerDependencyFunc new_func) { 683 UpdateWorkerDependencyFunc new_func) {
684 update_worker_dependency_ = new_func; 684 update_worker_dependency_ = new_func;
685 } 685 }
686 686
687 void SharedWorkerServiceImpl::ChangeTryIncrementWorkerRefCountFuncForTesting( 687 void SharedWorkerServiceImpl::ChangeTryIncrementWorkerRefCountFuncForTesting(
688 bool (*new_func)(int)) { 688 bool (*new_func)(int)) {
689 s_try_increment_worker_ref_count_ = new_func; 689 s_try_increment_worker_ref_count_ = new_func;
690 } 690 }
691 691
692 } // namespace content 692 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_process_manager.cc ('k') | content/browser/site_per_process_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698