| OLD | NEW |
| 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/tracing/tracing_controller_impl.h" | 5 #include "content/browser/tracing/tracing_controller_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/json/string_escape.h" | 10 #include "base/json/string_escape.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 : file_(NULL), | 60 : file_(NULL), |
| 61 path_(path), | 61 path_(path), |
| 62 has_at_least_one_result_(false) { | 62 has_at_least_one_result_(false) { |
| 63 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 63 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| 64 base::Bind(&TracingControllerImpl::ResultFile::OpenTask, | 64 base::Bind(&TracingControllerImpl::ResultFile::OpenTask, |
| 65 base::Unretained(this))); | 65 base::Unretained(this))); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void TracingControllerImpl::ResultFile::OpenTask() { | 68 void TracingControllerImpl::ResultFile::OpenTask() { |
| 69 if (path_.empty()) | 69 if (path_.empty()) |
| 70 file_util::CreateTemporaryFile(&path_); | 70 base::CreateTemporaryFile(&path_); |
| 71 file_ = file_util::OpenFile(path_, "w"); | 71 file_ = file_util::OpenFile(path_, "w"); |
| 72 if (!file_) { | 72 if (!file_) { |
| 73 LOG(ERROR) << "Failed to open " << path_.value(); | 73 LOG(ERROR) << "Failed to open " << path_.value(); |
| 74 return; | 74 return; |
| 75 } | 75 } |
| 76 const char* preamble = "{\"traceEvents\": ["; | 76 const char* preamble = "{\"traceEvents\": ["; |
| 77 size_t written = fwrite(preamble, strlen(preamble), 1, file_); | 77 size_t written = fwrite(preamble, strlen(preamble), 1, file_); |
| 78 DCHECK(written == 1); | 78 DCHECK(written == 1); |
| 79 } | 79 } |
| 80 | 80 |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 637 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 638 base::Bind(&TracingControllerImpl::OnWatchEventMatched, | 638 base::Bind(&TracingControllerImpl::OnWatchEventMatched, |
| 639 base::Unretained(this))); | 639 base::Unretained(this))); |
| 640 } | 640 } |
| 641 | 641 |
| 642 if (!watch_event_callback_.is_null()) | 642 if (!watch_event_callback_.is_null()) |
| 643 watch_event_callback_.Run(); | 643 watch_event_callback_.Run(); |
| 644 } | 644 } |
| 645 | 645 |
| 646 } // namespace content | 646 } // namespace content |
| OLD | NEW |