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

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

Issue 2105173004: 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"
14 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
16 #include "base/threading/non_thread_safe.h"
15 #include "base/trace_event/trace_event.h" 17 #include "base/trace_event/trace_event.h"
16 #include "content/common/devtools_messages.h" 18 #include "content/common/devtools_messages.h"
17 #include "content/common/frame_messages.h" 19 #include "content/common/frame_messages.h"
18 #include "content/public/common/manifest.h" 20 #include "content/public/common/manifest.h"
19 #include "content/renderer/devtools/devtools_client.h" 21 #include "content/renderer/devtools/devtools_client.h"
20 #include "content/renderer/devtools/devtools_cpu_throttler.h" 22 #include "content/renderer/devtools/devtools_cpu_throttler.h"
21 #include "content/renderer/manifest/manifest_manager.h" 23 #include "content/renderer/manifest/manifest_manager.h"
22 #include "content/renderer/render_frame_impl.h" 24 #include "content/renderer/render_frame_impl.h"
23 #include "content/renderer/render_widget.h" 25 #include "content/renderer/render_widget.h"
24 #include "ipc/ipc_channel.h" 26 #include "ipc/ipc_channel.h"
(...skipping 10 matching lines...) Expand all
35 37
36 using base::trace_event::TraceLog; 38 using base::trace_event::TraceLog;
37 39
38 namespace content { 40 namespace content {
39 41
40 namespace { 42 namespace {
41 43
42 const size_t kMaxMessageChunkSize = IPC::Channel::kMaximumMessageSize / 4; 44 const size_t kMaxMessageChunkSize = IPC::Channel::kMaximumMessageSize / 4;
43 const char kPageGetAppManifest[] = "Page.getAppManifest"; 45 const char kPageGetAppManifest[] = "Page.getAppManifest";
44 46
45
46 class WebKitClientMessageLoopImpl 47 class WebKitClientMessageLoopImpl
47 : public WebDevToolsAgentClient::WebKitClientMessageLoop { 48 : public WebDevToolsAgentClient::WebKitClientMessageLoop,
49 public base::NonThreadSafe {
48 public: 50 public:
49 WebKitClientMessageLoopImpl() : message_loop_(base::MessageLoop::current()) {} 51 WebKitClientMessageLoopImpl() { DCHECK(CalledOnValidThread()); }
50 ~WebKitClientMessageLoopImpl() override { message_loop_ = NULL; } 52 ~WebKitClientMessageLoopImpl() override { DCHECK(CalledOnValidThread()); }
51 void run() override { 53 void run() override {
52 base::MessageLoop::ScopedNestableTaskAllower allow(message_loop_); 54 DCHECK(CalledOnValidThread());
53 message_loop_->Run(); 55 base::MessageLoop::ScopedNestableTaskAllower allow(
56 base::MessageLoop::current());
57 run_loop_.Run();
54 } 58 }
55 void quitNow() override { message_loop_->QuitNow(); } 59 void quitNow() override {
60 DCHECK(CalledOnValidThread());
61 run_loop_.Quit();
62 }
56 63
57 private: 64 private:
58 base::MessageLoop* message_loop_; 65 base::RunLoop run_loop_;
59 }; 66 };
60 67
61 typedef std::map<int, DevToolsAgent*> IdToAgentMap; 68 typedef std::map<int, DevToolsAgent*> IdToAgentMap;
62 base::LazyInstance<IdToAgentMap>::Leaky 69 base::LazyInstance<IdToAgentMap>::Leaky
63 g_agent_for_routing_id = LAZY_INSTANCE_INITIALIZER; 70 g_agent_for_routing_id = LAZY_INSTANCE_INITIALIZER;
64 71
65 } // namespace 72 } // namespace
66 73
67 DevToolsAgent::DevToolsAgent(RenderFrameImpl* frame) 74 DevToolsAgent::DevToolsAgent(RenderFrameImpl* frame)
68 : RenderFrameObserver(frame), 75 : RenderFrameObserver(frame),
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 result->Set("errors", errors.release()); 330 result->Set("errors", errors.release());
324 response->Set("result", result.release()); 331 response->Set("result", result.release());
325 332
326 std::string json_message; 333 std::string json_message;
327 base::JSONWriter::Write(*response, &json_message); 334 base::JSONWriter::Write(*response, &json_message);
328 SendChunkedProtocolMessage(this, routing_id(), session_id, call_id, 335 SendChunkedProtocolMessage(this, routing_id(), session_id, call_id,
329 json_message, std::string()); 336 json_message, std::string());
330 } 337 }
331 338
332 } // namespace content 339 } // 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