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

Side by Side Diff: content/browser/browser_shutdown_profile_dumper.cc

Issue 1170623003: Revert "content: Remove use of MessageLoopProxy and deprecated MessageLoop APIs" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 | « content/browser/browser_main_loop.cc ('k') | content/browser/browser_thread_impl.cc » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/browser_shutdown_profile_dumper.h" 5 #include "content/browser/browser_shutdown_profile_dumper.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
11 #include "base/location.h"
12 #include "base/logging.h" 11 #include "base/logging.h"
13 #include "base/single_thread_task_runner.h"
14 #include "base/synchronization/waitable_event.h" 12 #include "base/synchronization/waitable_event.h"
15 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
16 #include "base/threading/thread_restrictions.h" 14 #include "base/threading/thread_restrictions.h"
17 #include "base/trace_event/trace_event.h" 15 #include "base/trace_event/trace_event.h"
18 #include "base/trace_event/trace_event_impl.h" 16 #include "base/trace_event/trace_event_impl.h"
19 #include "content/public/common/content_switches.h" 17 #include "content/public/common/content_switches.h"
20 18
21 namespace content { 19 namespace content {
22 20
23 BrowserShutdownProfileDumper::BrowserShutdownProfileDumper( 21 BrowserShutdownProfileDumper::BrowserShutdownProfileDumper(
(...skipping 30 matching lines...) Expand all
54 } 52 }
55 WriteString("{\"traceEvents\":"); 53 WriteString("{\"traceEvents\":");
56 WriteString("["); 54 WriteString("[");
57 55
58 // TraceLog::Flush() requires the calling thread to have a message loop. 56 // TraceLog::Flush() requires the calling thread to have a message loop.
59 // As the message loop of the current thread may have quit, start another 57 // As the message loop of the current thread may have quit, start another
60 // thread for flushing the trace. 58 // thread for flushing the trace.
61 base::WaitableEvent flush_complete_event(false, false); 59 base::WaitableEvent flush_complete_event(false, false);
62 base::Thread flush_thread("browser_shutdown_trace_event_flush"); 60 base::Thread flush_thread("browser_shutdown_trace_event_flush");
63 flush_thread.Start(); 61 flush_thread.Start();
64 flush_thread.task_runner()->PostTask( 62 flush_thread.message_loop()->PostTask(
65 FROM_HERE, base::Bind(&BrowserShutdownProfileDumper::EndTraceAndFlush, 63 FROM_HERE,
66 base::Unretained(this), 64 base::Bind(&BrowserShutdownProfileDumper::EndTraceAndFlush,
67 base::Unretained(&flush_complete_event))); 65 base::Unretained(this),
66 base::Unretained(&flush_complete_event)));
68 67
69 bool original_wait_allowed = base::ThreadRestrictions::SetWaitAllowed(true); 68 bool original_wait_allowed = base::ThreadRestrictions::SetWaitAllowed(true);
70 flush_complete_event.Wait(); 69 flush_complete_event.Wait();
71 base::ThreadRestrictions::SetWaitAllowed(original_wait_allowed); 70 base::ThreadRestrictions::SetWaitAllowed(original_wait_allowed);
72 } 71 }
73 72
74 void BrowserShutdownProfileDumper::EndTraceAndFlush( 73 void BrowserShutdownProfileDumper::EndTraceAndFlush(
75 base::WaitableEvent* flush_complete_event) { 74 base::WaitableEvent* flush_complete_event) {
76 base::trace_event::TraceLog::GetInstance()->SetDisabled(); 75 base::trace_event::TraceLog::GetInstance()->SetDisabled();
77 base::trace_event::TraceLog::GetInstance()->Flush( 76 base::trace_event::TraceLog::GetInstance()->Flush(
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 } 139 }
141 140
142 void BrowserShutdownProfileDumper::CloseFile() { 141 void BrowserShutdownProfileDumper::CloseFile() {
143 if (!dump_file_) 142 if (!dump_file_)
144 return; 143 return;
145 base::CloseFile(dump_file_); 144 base::CloseFile(dump_file_);
146 dump_file_ = NULL; 145 dump_file_ = NULL;
147 } 146 }
148 147
149 } // namespace content 148 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_main_loop.cc ('k') | content/browser/browser_thread_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698