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

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

Issue 2907273002: Replace deprecated base::NonThreadSafe in content/renderer/devtools in favor of SequenceChecker. (Closed)
Patch Set: Created 3 years, 6 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 | « no previous file | 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/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/run_loop.h"
15 #include "base/sequence_checker.h"
15 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
16 #include "base/threading/non_thread_safe.h"
17 #include "base/trace_event/trace_event.h" 17 #include "base/trace_event/trace_event.h"
18 #include "content/common/devtools_messages.h" 18 #include "content/common/devtools_messages.h"
19 #include "content/common/frame_messages.h" 19 #include "content/common/frame_messages.h"
20 #include "content/public/common/manifest.h" 20 #include "content/public/common/manifest.h"
21 #include "content/renderer/devtools/devtools_client.h" 21 #include "content/renderer/devtools/devtools_client.h"
22 #include "content/renderer/devtools/devtools_cpu_throttler.h" 22 #include "content/renderer/devtools/devtools_cpu_throttler.h"
23 #include "content/renderer/manifest/manifest_manager.h" 23 #include "content/renderer/manifest/manifest_manager.h"
24 #include "content/renderer/render_frame_impl.h" 24 #include "content/renderer/render_frame_impl.h"
25 #include "content/renderer/render_widget.h" 25 #include "content/renderer/render_widget.h"
26 #include "ipc/ipc_channel.h" 26 #include "ipc/ipc_channel.h"
(...skipping 12 matching lines...) Expand all
39 using base::trace_event::TraceLog; 39 using base::trace_event::TraceLog;
40 40
41 namespace content { 41 namespace content {
42 42
43 namespace { 43 namespace {
44 44
45 const size_t kMaxMessageChunkSize = IPC::Channel::kMaximumMessageSize / 4; 45 const size_t kMaxMessageChunkSize = IPC::Channel::kMaximumMessageSize / 4;
46 const char kPageGetAppManifest[] = "Page.getAppManifest"; 46 const char kPageGetAppManifest[] = "Page.getAppManifest";
47 47
48 class WebKitClientMessageLoopImpl 48 class WebKitClientMessageLoopImpl
49 : public WebDevToolsAgentClient::WebKitClientMessageLoop, 49 : public WebDevToolsAgentClient::WebKitClientMessageLoop {
50 public base::NonThreadSafe {
51 public: 50 public:
52 WebKitClientMessageLoopImpl() = default; 51 WebKitClientMessageLoopImpl() = default;
53 ~WebKitClientMessageLoopImpl() override { DCHECK(CalledOnValidThread()); } 52 ~WebKitClientMessageLoopImpl() override {
53 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
54 }
54 void Run() override { 55 void Run() override {
55 DCHECK(CalledOnValidThread()); 56 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
56 57
57 base::RunLoop* const previous_run_loop = run_loop_; 58 base::RunLoop* const previous_run_loop = run_loop_;
58 base::RunLoop run_loop; 59 base::RunLoop run_loop;
59 run_loop_ = &run_loop; 60 run_loop_ = &run_loop;
60 61
61 base::MessageLoop::ScopedNestableTaskAllower allow( 62 base::MessageLoop::ScopedNestableTaskAllower allow(
62 base::MessageLoop::current()); 63 base::MessageLoop::current());
63 run_loop.Run(); 64 run_loop.Run();
64 65
65 run_loop_ = previous_run_loop; 66 run_loop_ = previous_run_loop;
66 } 67 }
67 void QuitNow() override { 68 void QuitNow() override {
68 DCHECK(CalledOnValidThread()); 69 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
69 DCHECK(run_loop_); 70 DCHECK(run_loop_);
70 71
71 run_loop_->Quit(); 72 run_loop_->Quit();
72 } 73 }
73 74
74 private: 75 private:
75 base::RunLoop* run_loop_ = nullptr; 76 base::RunLoop* run_loop_ = nullptr;
77
78 SEQUENCE_CHECKER(sequence_checker_);
76 }; 79 };
77 80
78 typedef std::map<int, DevToolsAgent*> IdToAgentMap; 81 typedef std::map<int, DevToolsAgent*> IdToAgentMap;
79 base::LazyInstance<IdToAgentMap>::Leaky 82 base::LazyInstance<IdToAgentMap>::Leaky
80 g_agent_for_routing_id = LAZY_INSTANCE_INITIALIZER; 83 g_agent_for_routing_id = LAZY_INSTANCE_INITIALIZER;
81 84
82 } // namespace 85 } // namespace
83 86
84 DevToolsAgent::DevToolsAgent(RenderFrameImpl* frame) 87 DevToolsAgent::DevToolsAgent(RenderFrameImpl* frame)
85 : RenderFrameObserver(frame), 88 : RenderFrameObserver(frame),
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 result->Set("errors", errors.release()); 344 result->Set("errors", errors.release());
342 response->Set("result", result.release()); 345 response->Set("result", result.release());
343 346
344 std::string json_message; 347 std::string json_message;
345 base::JSONWriter::Write(*response, &json_message); 348 base::JSONWriter::Write(*response, &json_message);
346 SendChunkedProtocolMessage(this, routing_id(), session_id, call_id, 349 SendChunkedProtocolMessage(this, routing_id(), session_id, call_id,
347 json_message, std::string()); 350 json_message, std::string());
348 } 351 }
349 352
350 } // namespace content 353 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698