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 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 cast_channel::CHANNEL_ERROR_SOCKET_ERROR); | 470 cast_channel::CHANNEL_ERROR_SOCKET_ERROR); |
471 } else { | 471 } else { |
472 SetResultFromSocket(*socket); | 472 SetResultFromSocket(*socket); |
473 // This will delete |socket|. | 473 // This will delete |socket|. |
474 RemoveSocket(channel_id); | 474 RemoveSocket(channel_id); |
475 socket = NULL; | 475 socket = NULL; |
476 } | 476 } |
477 AsyncWorkCompleted(); | 477 AsyncWorkCompleted(); |
478 } | 478 } |
479 | 479 |
| 480 CastChannelGetLogsFunction::CastChannelGetLogsFunction() { |
| 481 } |
| 482 |
| 483 CastChannelGetLogsFunction::~CastChannelGetLogsFunction() { |
| 484 } |
| 485 |
| 486 bool CastChannelGetLogsFunction::PrePrepare() { |
| 487 api_ = CastChannelAPI::Get(browser_context()); |
| 488 return CastChannelAsyncApiFunction::PrePrepare(); |
| 489 } |
| 490 |
| 491 bool CastChannelGetLogsFunction::Prepare() { |
| 492 return true; |
| 493 } |
| 494 |
| 495 void CastChannelGetLogsFunction::AsyncWorkStart() { |
| 496 DCHECK(api_); |
| 497 |
| 498 size_t length = 0; |
| 499 scoped_ptr<char[]> out = api_->GetLogger()->GetLogs(&length); |
| 500 if (out.get()) { |
| 501 SetResult(new base::BinaryValue(out.Pass(), length)); |
| 502 } else { |
| 503 SetError("Unable to get logs."); |
| 504 } |
| 505 |
| 506 api_->GetLogger()->Reset(); |
| 507 |
| 508 AsyncWorkCompleted(); |
| 509 } |
| 510 |
480 } // namespace extensions | 511 } // namespace extensions |
OLD | NEW |