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

Side by Side Diff: content/worker/websharedworker_stub.cc

Issue 268623009: Introduce enablePreciseMemoryInfo switch and apply it to both renderer and shared worker (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: for landing Created 6 years, 7 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/public/common/content_switches.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/worker/websharedworker_stub.h" 5 #include "content/worker/websharedworker_stub.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "content/child/child_process.h" 9 #include "content/child/child_process.h"
10 #include "content/child/child_thread.h" 10 #include "content/child/child_thread.h"
11 #include "content/child/fileapi/file_system_dispatcher.h" 11 #include "content/child/fileapi/file_system_dispatcher.h"
12 #include "content/child/shared_worker_devtools_agent.h" 12 #include "content/child/shared_worker_devtools_agent.h"
13 #include "content/child/webmessageportchannel_impl.h" 13 #include "content/child/webmessageportchannel_impl.h"
14 #include "content/common/worker_messages.h" 14 #include "content/common/worker_messages.h"
15 #include "content/public/common/content_switches.h" 15 #include "content/public/common/content_switches.h"
16 #include "content/worker/worker_thread.h" 16 #include "content/worker/worker_thread.h"
17 #include "third_party/WebKit/public/platform/WebString.h" 17 #include "third_party/WebKit/public/platform/WebString.h"
18 #include "third_party/WebKit/public/platform/WebURL.h" 18 #include "third_party/WebKit/public/platform/WebURL.h"
19 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
20 #include "third_party/WebKit/public/web/WebSharedWorker.h" 19 #include "third_party/WebKit/public/web/WebSharedWorker.h"
21 20
22 namespace content { 21 namespace content {
23 22
24 WebSharedWorkerStub::WebSharedWorkerStub( 23 WebSharedWorkerStub::WebSharedWorkerStub(
25 const GURL& url, 24 const GURL& url,
26 const base::string16& name, 25 const base::string16& name,
27 const base::string16& content_security_policy, 26 const base::string16& content_security_policy,
28 blink::WebContentSecurityPolicyType security_policy_type, 27 blink::WebContentSecurityPolicyType security_policy_type,
29 bool pause_on_start, 28 bool pause_on_start,
30 int route_id) 29 int route_id)
31 : route_id_(route_id), 30 : route_id_(route_id),
32 client_(route_id, this), 31 client_(route_id, this),
33 running_(false), 32 running_(false),
34 url_(url) { 33 url_(url) {
35 34
36 WorkerThread* worker_thread = WorkerThread::current(); 35 WorkerThread* worker_thread = WorkerThread::current();
37 DCHECK(worker_thread); 36 DCHECK(worker_thread);
38 worker_thread->AddWorkerStub(this); 37 worker_thread->AddWorkerStub(this);
39 // Start processing incoming IPCs for this worker. 38 // Start processing incoming IPCs for this worker.
40 worker_thread->GetRouter()->AddRoute(route_id_, this); 39 worker_thread->GetRouter()->AddRoute(route_id_, this);
41 40
42 // TODO(atwilson): Add support for NaCl when they support MessagePorts. 41 // TODO(atwilson): Add support for NaCl when they support MessagePorts.
43 impl_ = blink::WebSharedWorker::create(client()); 42 impl_ = blink::WebSharedWorker::create(client());
44 if (pause_on_start) { 43 if (pause_on_start) {
45 // Pause worker context when it starts and wait until either DevTools client 44 // Pause worker context when it starts and wait until either DevTools client
46 // is attached or explicit resume notification is received. 45 // is attached or explicit resume notification is received.
47 impl_->pauseWorkerContextOnStart(); 46 impl_->pauseWorkerContextOnStart();
48 } 47 }
49 blink::WebRuntimeFeatures::enablePreciseMemoryInfo(
50 CommandLine::ForCurrentProcess()->HasSwitch(
51 switches::kEnableSharedWorkerMemoryInfo));
52 48
53 worker_devtools_agent_.reset(new SharedWorkerDevToolsAgent(route_id, impl_)); 49 worker_devtools_agent_.reset(new SharedWorkerDevToolsAgent(route_id, impl_));
54 client()->set_devtools_agent(worker_devtools_agent_.get()); 50 client()->set_devtools_agent(worker_devtools_agent_.get());
55 impl_->startWorkerContext(url_, name, 51 impl_->startWorkerContext(url_, name,
56 content_security_policy, security_policy_type); 52 content_security_policy, security_policy_type);
57 } 53 }
58 54
59 WebSharedWorkerStub::~WebSharedWorkerStub() { 55 WebSharedWorkerStub::~WebSharedWorkerStub() {
60 impl_->clientDestroyed(); 56 impl_->clientDestroyed();
61 WorkerThread* worker_thread = WorkerThread::current(); 57 WorkerThread* worker_thread = WorkerThread::current();
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 iter != pending_channels_.end(); 137 iter != pending_channels_.end();
142 ++iter) { 138 ++iter) {
143 blink::WebMessagePortChannel* channel = *iter; 139 blink::WebMessagePortChannel* channel = *iter;
144 channel->destroy(); 140 channel->destroy();
145 } 141 }
146 pending_channels_.clear(); 142 pending_channels_.clear();
147 Shutdown(); 143 Shutdown();
148 } 144 }
149 145
150 } // namespace content 146 } // namespace content
OLDNEW
« no previous file with comments | « content/public/common/content_switches.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698