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

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: Addressed comments 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 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 int length = 0;
475 scoped_ptr<char[]> out = api_->GetLogger()->GetLogs(&length);
476 if (out.get()) {
477 SetResult(new base::BinaryValue(out.Pass(), length));
478 } else {
479 SetError("Unable to get logs.");
480 }
481
482 api_->GetLogger()->Reset();
483
484 AsyncWorkCompleted();
485 }
486
456 } // namespace extensions 487 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698