Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Side by Side Diff: extensions/browser/api/cast_channel/cast_channel_api.cc

Issue 456213002: Cast channel: Add cast.channel.getLogs extension API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
OLDNEW
« no previous file with comments | « extensions/browser/api/cast_channel/cast_channel_api.h ('k') | extensions/browser/api/cast_channel/cast_channel_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698