diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-03 03:28:20 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-03 03:28:20 +0000 |
commit | a9dfd3d2dac6bcca200e2930fa67ca8af4568f62 (patch) | |
tree | d8d5c01df670af3fc746a27f7f3c5417005a3a76 /content/browser/tracing/trace_subscriber_stdio.cc | |
parent | 897f248b8c76aad540f4ea1bea4b5bbc42dbea0f (diff) | |
download | chromium_src-a9dfd3d2dac6bcca200e2930fa67ca8af4568f62.zip chromium_src-a9dfd3d2dac6bcca200e2930fa67ca8af4568f62.tar.gz chromium_src-a9dfd3d2dac6bcca200e2930fa67ca8af4568f62.tar.bz2 |
Revert 180055: Very likely caused http://crbug.com/173885
> Moving chrome://tracing to content.
>
> BUG=169170
> Review URL: https://codereview.chromium.org/12088099
TBR=jam@chromium.org
Review URL: https://codereview.chromium.org/12194007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180282 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/tracing/trace_subscriber_stdio.cc')
-rw-r--r-- | content/browser/tracing/trace_subscriber_stdio.cc | 104 |
1 files changed, 0 insertions, 104 deletions
diff --git a/content/browser/tracing/trace_subscriber_stdio.cc b/content/browser/tracing/trace_subscriber_stdio.cc deleted file mode 100644 index d366f1b..0000000 --- a/content/browser/tracing/trace_subscriber_stdio.cc +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/browser/tracing/trace_subscriber_stdio.h" - -#include "base/bind.h" -#include "base/debug/trace_event.h" -#include "base/logging.h" -#include "base/threading/sequenced_worker_pool.h" -#include "content/public/browser/browser_thread.h" - -namespace content { - -// All method calls on this class are done on a SequencedWorkerPool thread. -class TraceSubscriberStdioImpl - : public base::RefCountedThreadSafe<TraceSubscriberStdioImpl> { - public: - explicit TraceSubscriberStdioImpl(const FilePath& path) - : path_(path), - file_(0) {} - - void OnStart() { - DCHECK(!file_); - trace_buffer_.SetOutputCallback( - base::Bind(&TraceSubscriberStdioImpl::Write, this)); - file_ = file_util::OpenFile(path_, "w+"); - if (IsValid()) { - LOG(INFO) << "Logging performance trace to file: " << path_.value(); - trace_buffer_.Start(); - } else { - LOG(ERROR) << "Failed to open performance trace file: " << path_.value(); - } - } - - void OnData(const scoped_refptr<base::RefCountedString>& data_ptr) { - trace_buffer_.AddFragment(data_ptr->data()); - } - - void OnEnd() { - trace_buffer_.Finish(); - CloseFile(); - } - - private: - friend class base::RefCountedThreadSafe<TraceSubscriberStdioImpl>; - - ~TraceSubscriberStdioImpl() { - CloseFile(); - } - - bool IsValid() const { - return file_ && (0 == ferror(file_)); - } - - void CloseFile() { - if (file_) { - fclose(file_); - file_ = 0; - } - // This is important, as it breaks a reference cycle. - trace_buffer_.SetOutputCallback( - base::debug::TraceResultBuffer::OutputCallback()); - } - - void Write(const std::string& output_str) { - if (IsValid()) { - size_t written = fwrite(output_str.data(), 1, output_str.size(), file_); - if (written != output_str.size()) { - LOG(ERROR) << "Error " << ferror(file_) << " in fwrite() to trace file"; - CloseFile(); - } - } - } - - FilePath path_; - FILE* file_; - base::debug::TraceResultBuffer trace_buffer_; -}; - -TraceSubscriberStdio::TraceSubscriberStdio(const FilePath& path) - : impl_(new TraceSubscriberStdioImpl(path)) { - BrowserThread::PostBlockingPoolSequencedTask( - __FILE__, FROM_HERE, - base::Bind(&TraceSubscriberStdioImpl::OnStart, impl_)); -} - -TraceSubscriberStdio::~TraceSubscriberStdio() { -} - -void TraceSubscriberStdio::OnEndTracingComplete() { - BrowserThread::PostBlockingPoolSequencedTask( - __FILE__, FROM_HERE, - base::Bind(&TraceSubscriberStdioImpl::OnEnd, impl_)); -} - -void TraceSubscriberStdio::OnTraceDataCollected( - const scoped_refptr<base::RefCountedString>& data_ptr) { - BrowserThread::PostBlockingPoolSequencedTask( - __FILE__, FROM_HERE, - base::Bind(&TraceSubscriberStdioImpl::OnData, impl_, data_ptr)); -} - -} // namespace content |