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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: extensions/browser/api/cast_channel/cast_channel_api.cc
diff --git a/extensions/browser/api/cast_channel/cast_channel_api.cc b/extensions/browser/api/cast_channel/cast_channel_api.cc
index 1fdc364b87b8f98158a81dff5247d8fa1a7b8a49..4bae9c139d7b6c7aac5cd0fd77cf991709759052 100644
--- a/extensions/browser/api/cast_channel/cast_channel_api.cc
+++ b/extensions/browser/api/cast_channel/cast_channel_api.cc
@@ -477,4 +477,35 @@ void CastChannelCloseFunction::OnClose(int result) {
AsyncWorkCompleted();
}
+CastChannelGetLogsFunction::CastChannelGetLogsFunction() {
+}
+
+CastChannelGetLogsFunction::~CastChannelGetLogsFunction() {
+}
+
+bool CastChannelGetLogsFunction::PrePrepare() {
+ api_ = CastChannelAPI::Get(browser_context());
+ return CastChannelAsyncApiFunction::PrePrepare();
+}
+
+bool CastChannelGetLogsFunction::Prepare() {
+ return true;
+}
+
+void CastChannelGetLogsFunction::AsyncWorkStart() {
+ DCHECK(api_);
+
+ size_t length = 0;
+ scoped_ptr<char[]> out = api_->GetLogger()->GetLogs(&length);
+ if (out.get()) {
+ SetResult(new base::BinaryValue(out.Pass(), length));
+ } else {
+ SetError("Unable to get logs.");
+ }
+
+ api_->GetLogger()->Reset();
+
+ AsyncWorkCompleted();
+}
+
} // namespace extensions
« 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