OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/debugger/devtools_trace_domain_handler.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/callback.h" |
| 9 #include "base/location.h" |
| 10 #include "content/public/browser/browser_thread.h" |
| 11 #include "content/public/browser/trace_controller.h" |
| 12 #include "content/public/browser/trace_subscriber.h" |
| 13 #include "content/browser/debugger/devtools_http_handler_impl.h" |
| 14 |
| 15 namespace content { |
| 16 |
| 17 DevToolsTraceDomainHandler::DevToolsTraceDomainHandler() |
| 18 : has_completed_(false) { |
| 19 } |
| 20 |
| 21 DevToolsTraceDomainHandler::~DevToolsTraceDomainHandler() { |
| 22 } |
| 23 |
| 24 void DevToolsTraceDomainHandler::BeginTracing(const std::string& categories) { |
| 25 TraceController::GetInstance()->BeginTracing(this, categories); |
| 26 } |
| 27 |
| 28 void DevToolsTraceDomainHandler::EndTracingAsync() { |
| 29 TraceController::GetInstance()->EndTracingAsync(this); |
| 30 } |
| 31 |
| 32 bool DevToolsTraceDomainHandler::OnWebSocketMessage( |
| 33 int connection_id, const std::string& data, DevToolsServerSender* sender) { |
| 34 sender->Send200(connection_id, data, "foo/bar"); |
| 35 return true; |
| 36 } |
| 37 |
| 38 |
| 39 bool DevToolsTraceDomainHandler::has_completed() const { |
| 40 return has_completed_; |
| 41 } |
| 42 |
| 43 void DevToolsTraceDomainHandler::OnEndTracingComplete() { |
| 44 has_completed_ = true; |
| 45 } |
| 46 |
| 47 void DevToolsTraceDomainHandler::OnTraceDataCollected( |
| 48 const scoped_refptr<base::RefCountedString>& trace_fragment) { |
| 49 if (!buffer_.empty()) |
| 50 buffer_.append(","); |
| 51 buffer_.append(trace_fragment->data()); |
| 52 } |
| 53 |
| 54 std::string DevToolsTraceDomainHandler::GetAndResetTrace() { |
| 55 std::string ret(buffer_); |
| 56 buffer_.clear(); |
| 57 has_completed_ = false; |
| 58 return ret; |
| 59 } |
| 60 |
| 61 } // namespace content |
OLD | NEW |