Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/api/cast_channel/cast_channel_api.h" | 5 #include "extensions/browser/api/cast_channel/cast_channel_api.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 446 cast_channel::CHANNEL_ERROR_SOCKET_ERROR); | 446 cast_channel::CHANNEL_ERROR_SOCKET_ERROR); |
| 447 } else { | 447 } else { |
| 448 SetResultFromSocket(*socket); | 448 SetResultFromSocket(*socket); |
| 449 // This will delete |socket|. | 449 // This will delete |socket|. |
| 450 RemoveSocket(channel_id); | 450 RemoveSocket(channel_id); |
| 451 socket = NULL; | 451 socket = NULL; |
| 452 } | 452 } |
| 453 AsyncWorkCompleted(); | 453 AsyncWorkCompleted(); |
| 454 } | 454 } |
| 455 | 455 |
| 456 CastChannelGetLogsFunction::CastChannelGetLogsFunction() { | |
| 457 } | |
| 458 | |
| 459 CastChannelGetLogsFunction::~CastChannelGetLogsFunction() { | |
| 460 } | |
| 461 | |
| 462 bool CastChannelGetLogsFunction::PrePrepare() { | |
| 463 api_ = CastChannelAPI::Get(browser_context()); | |
| 464 return CastChannelAsyncApiFunction::PrePrepare(); | |
| 465 } | |
| 466 | |
| 467 bool CastChannelGetLogsFunction::Prepare() { | |
| 468 return true; | |
| 469 } | |
| 470 | |
| 471 void CastChannelGetLogsFunction::AsyncWorkStart() { | |
| 472 DCHECK(api_); | |
| 473 | |
| 474 std::string log; | |
| 475 if (api_->GetLogger()->LogToString(&log)) { | |
|
mark a. foltz
2014/08/11 23:01:43
How about having a LogToValue() method that can ha
imcheng
2014/08/12 07:42:09
Yes, that's possible by asking zlib for the compre
| |
| 476 base::BinaryValue* result = | |
| 477 base::BinaryValue::CreateWithCopiedBuffer(&log[0], log.size()); | |
|
mark a. foltz
2014/08/11 23:01:43
log.data()
imcheng
2014/08/12 07:42:09
Done.
| |
| 478 SetResult(result); | |
| 479 } else { | |
| 480 SetResult(new base::BinaryValue()); | |
|
mark a. foltz
2014/08/11 23:01:43
Does this mean no events were logged? Or is this
imcheng
2014/08/12 07:42:09
If no events is logged then a blob representing an
| |
| 481 } | |
| 482 | |
| 483 api_->GetLogger()->Reset(); | |
| 484 | |
| 485 AsyncWorkCompleted(); | |
| 486 } | |
| 487 | |
| 456 } // namespace extensions | 488 } // namespace extensions |
| OLD | NEW |