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

Side by Side Diff: content/renderer/devtools/devtools_agent.cc

Issue 2116643002: Revert of Remove calls to MessageLoop::current() in content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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/ppapi_plugin/ppapi_thread.cc ('k') | content/renderer/devtools/devtools_agent_filter.h » ('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 (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/renderer/devtools/devtools_agent.h" 5 #include "content/renderer/devtools/devtools_agent.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 10
11 #include "base/json/json_writer.h" 11 #include "base/json/json_writer.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/run_loop.h"
15 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
16 #include "base/threading/non_thread_safe.h"
17 #include "base/trace_event/trace_event.h" 15 #include "base/trace_event/trace_event.h"
18 #include "content/common/devtools_messages.h" 16 #include "content/common/devtools_messages.h"
19 #include "content/common/frame_messages.h" 17 #include "content/common/frame_messages.h"
20 #include "content/public/common/manifest.h" 18 #include "content/public/common/manifest.h"
21 #include "content/renderer/devtools/devtools_client.h" 19 #include "content/renderer/devtools/devtools_client.h"
22 #include "content/renderer/devtools/devtools_cpu_throttler.h" 20 #include "content/renderer/devtools/devtools_cpu_throttler.h"
23 #include "content/renderer/manifest/manifest_manager.h" 21 #include "content/renderer/manifest/manifest_manager.h"
24 #include "content/renderer/render_frame_impl.h" 22 #include "content/renderer/render_frame_impl.h"
25 #include "content/renderer/render_widget.h" 23 #include "content/renderer/render_widget.h"
26 #include "ipc/ipc_channel.h" 24 #include "ipc/ipc_channel.h"
(...skipping 10 matching lines...) Expand all
37 35
38 using base::trace_event::TraceLog; 36 using base::trace_event::TraceLog;
39 37
40 namespace content { 38 namespace content {
41 39
42 namespace { 40 namespace {
43 41
44 const size_t kMaxMessageChunkSize = IPC::Channel::kMaximumMessageSize / 4; 42 const size_t kMaxMessageChunkSize = IPC::Channel::kMaximumMessageSize / 4;
45 const char kPageGetAppManifest[] = "Page.getAppManifest"; 43 const char kPageGetAppManifest[] = "Page.getAppManifest";
46 44
45
47 class WebKitClientMessageLoopImpl 46 class WebKitClientMessageLoopImpl
48 : public WebDevToolsAgentClient::WebKitClientMessageLoop, 47 : public WebDevToolsAgentClient::WebKitClientMessageLoop {
49 public base::NonThreadSafe {
50 public: 48 public:
51 WebKitClientMessageLoopImpl() { DCHECK(CalledOnValidThread()); } 49 WebKitClientMessageLoopImpl() : message_loop_(base::MessageLoop::current()) {}
52 ~WebKitClientMessageLoopImpl() override { DCHECK(CalledOnValidThread()); } 50 ~WebKitClientMessageLoopImpl() override { message_loop_ = NULL; }
53 void run() override { 51 void run() override {
54 DCHECK(CalledOnValidThread()); 52 base::MessageLoop::ScopedNestableTaskAllower allow(message_loop_);
55 base::MessageLoop::ScopedNestableTaskAllower allow( 53 message_loop_->Run();
56 base::MessageLoop::current());
57 run_loop_.Run();
58 } 54 }
59 void quitNow() override { 55 void quitNow() override { message_loop_->QuitNow(); }
60 DCHECK(CalledOnValidThread());
61 run_loop_.Quit();
62 }
63 56
64 private: 57 private:
65 base::RunLoop run_loop_; 58 base::MessageLoop* message_loop_;
66 }; 59 };
67 60
68 typedef std::map<int, DevToolsAgent*> IdToAgentMap; 61 typedef std::map<int, DevToolsAgent*> IdToAgentMap;
69 base::LazyInstance<IdToAgentMap>::Leaky 62 base::LazyInstance<IdToAgentMap>::Leaky
70 g_agent_for_routing_id = LAZY_INSTANCE_INITIALIZER; 63 g_agent_for_routing_id = LAZY_INSTANCE_INITIALIZER;
71 64
72 } // namespace 65 } // namespace
73 66
74 DevToolsAgent::DevToolsAgent(RenderFrameImpl* frame) 67 DevToolsAgent::DevToolsAgent(RenderFrameImpl* frame)
75 : RenderFrameObserver(frame), 68 : RenderFrameObserver(frame),
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 result->Set("errors", errors.release()); 323 result->Set("errors", errors.release());
331 response->Set("result", result.release()); 324 response->Set("result", result.release());
332 325
333 std::string json_message; 326 std::string json_message;
334 base::JSONWriter::Write(*response, &json_message); 327 base::JSONWriter::Write(*response, &json_message);
335 SendChunkedProtocolMessage(this, routing_id(), session_id, call_id, 328 SendChunkedProtocolMessage(this, routing_id(), session_id, call_id,
336 json_message, std::string()); 329 json_message, std::string());
337 } 330 }
338 331
339 } // namespace content 332 } // namespace content
OLDNEW
« no previous file with comments | « content/ppapi_plugin/ppapi_thread.cc ('k') | content/renderer/devtools/devtools_agent_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698