| OLD | NEW |
| 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/browser/devtools/devtools_tracing_handler.h" | 5 #include "content/browser/devtools/devtools_tracing_handler.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "content/browser/devtools/devtools_protocol_constants.h" | 23 #include "content/browser/devtools/devtools_protocol_constants.h" |
| 24 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
| 25 #include "content/public/browser/tracing_controller.h" | 25 #include "content/public/browser/tracing_controller.h" |
| 26 | 26 |
| 27 namespace content { | 27 namespace content { |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 const char kRecordUntilFull[] = "record-until-full"; | 31 const char kRecordUntilFull[] = "record-until-full"; |
| 32 const char kRecordContinuously[] = "record-continuously"; | 32 const char kRecordContinuously[] = "record-continuously"; |
| 33 const char kRecordAsMuchAsPossible[] = "record-as-much-as-possible"; |
| 33 const char kEnableSampling[] = "enable-sampling"; | 34 const char kEnableSampling[] = "enable-sampling"; |
| 34 | 35 |
| 35 void ReadFile( | 36 void ReadFile( |
| 36 const base::FilePath& path, | 37 const base::FilePath& path, |
| 37 const base::Callback<void(const scoped_refptr<base::RefCountedString>&)> | 38 const base::Callback<void(const scoped_refptr<base::RefCountedString>&)> |
| 38 callback) { | 39 callback) { |
| 39 std::string trace_data; | 40 std::string trace_data; |
| 40 if (!base::ReadFileToString(path, &trace_data)) | 41 if (!base::ReadFileToString(path, &trace_data)) |
| 41 LOG(ERROR) << "Failed to read file: " << path.value(); | 42 LOG(ERROR) << "Failed to read file: " << path.value(); |
| 42 base::DeleteFile(path, false); | 43 base::DeleteFile(path, false); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 std::vector<std::string> split; | 135 std::vector<std::string> split; |
| 135 std::vector<std::string>::iterator iter; | 136 std::vector<std::string>::iterator iter; |
| 136 base::debug::TraceOptions ret; | 137 base::debug::TraceOptions ret; |
| 137 | 138 |
| 138 base::SplitString(options, ',', &split); | 139 base::SplitString(options, ',', &split); |
| 139 for (iter = split.begin(); iter != split.end(); ++iter) { | 140 for (iter = split.begin(); iter != split.end(); ++iter) { |
| 140 if (*iter == kRecordUntilFull) { | 141 if (*iter == kRecordUntilFull) { |
| 141 ret.record_mode = base::debug::RECORD_UNTIL_FULL; | 142 ret.record_mode = base::debug::RECORD_UNTIL_FULL; |
| 142 } else if (*iter == kRecordContinuously) { | 143 } else if (*iter == kRecordContinuously) { |
| 143 ret.record_mode = base::debug::RECORD_CONTINUOUSLY; | 144 ret.record_mode = base::debug::RECORD_CONTINUOUSLY; |
| 145 } else if (*iter == kRecordAsMuchAsPossible) { |
| 146 ret.record_mode = base::debug::RECORD_AS_MUCH_AS_POSSIBLE; |
| 144 } else if (*iter == kEnableSampling) { | 147 } else if (*iter == kEnableSampling) { |
| 145 ret.enable_sampling = true; | 148 ret.enable_sampling = true; |
| 146 } | 149 } |
| 147 } | 150 } |
| 148 return ret; | 151 return ret; |
| 149 } | 152 } |
| 150 | 153 |
| 151 scoped_refptr<DevToolsProtocol::Response> | 154 scoped_refptr<DevToolsProtocol::Response> |
| 152 DevToolsTracingHandler::OnStart( | 155 DevToolsTracingHandler::OnStart( |
| 153 scoped_refptr<DevToolsProtocol::Command> command) { | 156 scoped_refptr<DevToolsProtocol::Command> command) { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 if (!is_recording_) | 291 if (!is_recording_) |
| 289 return; | 292 return; |
| 290 is_recording_ = false; | 293 is_recording_ = false; |
| 291 DisableRecording( | 294 DisableRecording( |
| 292 base::Bind(&DevToolsTracingHandler::BeginReadingRecordingResult, | 295 base::Bind(&DevToolsTracingHandler::BeginReadingRecordingResult, |
| 293 weak_factory_.GetWeakPtr())); | 296 weak_factory_.GetWeakPtr())); |
| 294 } | 297 } |
| 295 | 298 |
| 296 | 299 |
| 297 } // namespace content | 300 } // namespace content |
| OLD | NEW |