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 b8fd3b2b64e75a17da811befc06427924d633d79..29e111cfac9675874cf936beba886b3ed4632e9a 100644 |
--- a/extensions/browser/api/cast_channel/cast_channel_api.cc |
+++ b/extensions/browser/api/cast_channel/cast_channel_api.cc |
@@ -16,7 +16,6 @@ |
#include "base/lazy_instance.h" |
#include "base/memory/ptr_util.h" |
#include "base/strings/string_number_conversions.h" |
-#include "base/time/default_clock.h" |
#include "base/values.h" |
#include "content/public/browser/browser_thread.h" |
#include "extensions/browser/api/cast_channel/cast_message_util.h" |
@@ -109,9 +108,7 @@ bool IsValidConnectInfoIpAddress(const ConnectInfo& connect_info) { |
} // namespace |
CastChannelAPI::CastChannelAPI(content::BrowserContext* context) |
- : browser_context_(context), |
- logger_(new Logger(base::WrapUnique<base::Clock>(new base::DefaultClock), |
- base::Time::UnixEpoch())) { |
+ : browser_context_(context), logger_(new Logger()) { |
DCHECK(browser_context_); |
} |
@@ -320,7 +317,6 @@ void CastChannelOpenFunction::AsyncWorkStart() { |
: CastDeviceCapability::NONE); |
} |
new_channel_id_ = AddSocket(socket); |
- api_->GetLogger()->LogNewSocketEvent(*socket); |
// Construct read delegates. |
std::unique_ptr<api::cast_channel::CastTransport::Delegate> delegate( |
@@ -342,7 +338,6 @@ void CastChannelOpenFunction::AsyncWorkStart() { |
delegate.reset(keep_alive); |
} |
- api_->GetLogger()->LogNewSocketEvent(*socket); |
socket->Connect(std::move(delegate), |
base::Bind(&CastChannelOpenFunction::OnOpen, this)); |
} |
@@ -425,6 +420,11 @@ CastChannelCloseFunction::CastChannelCloseFunction() { } |
CastChannelCloseFunction::~CastChannelCloseFunction() { } |
+bool CastChannelCloseFunction::PrePrepare() { |
+ api_ = CastChannelAPI::Get(browser_context()); |
+ return CastChannelAsyncApiFunction::PrePrepare(); |
+} |
+ |
bool CastChannelCloseFunction::Prepare() { |
params_ = Close::Params::Create(*args_); |
EXTENSION_FUNCTION_VALIDATE(params_.get()); |
@@ -454,41 +454,11 @@ void CastChannelCloseFunction::OnClose(int result) { |
SetResultFromSocket(*socket); |
// This will delete |socket|. |
RemoveSocket(channel_id); |
+ api_->GetLogger()->ClearLastErrors(channel_id); |
} |
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; |
- std::unique_ptr<char[]> out = api_->GetLogger()->GetLogs(&length); |
- if (out.get()) { |
- SetResult(base::MakeUnique<base::BinaryValue>(std::move(out), length)); |
- } else { |
- SetError("Unable to get logs."); |
- } |
- |
- api_->GetLogger()->Reset(); |
- |
- AsyncWorkCompleted(); |
-} |
- |
CastChannelOpenFunction::CastMessageHandler::CastMessageHandler( |
const EventDispatchCallback& ui_dispatch_cb, |
cast_channel::CastSocket* socket, |
@@ -547,20 +517,4 @@ void CastChannelOpenFunction::CastMessageHandler::OnMessage( |
void CastChannelOpenFunction::CastMessageHandler::Start() { |
} |
-CastChannelSetAuthorityKeysFunction::CastChannelSetAuthorityKeysFunction() { |
-} |
- |
-CastChannelSetAuthorityKeysFunction::~CastChannelSetAuthorityKeysFunction() { |
-} |
- |
-bool CastChannelSetAuthorityKeysFunction::Prepare() { |
- return true; |
-} |
- |
-void CastChannelSetAuthorityKeysFunction::AsyncWorkStart() { |
- // TODO(eroman): crbug.com/601171: Delete this once the API is |
- // removed. It is currently a no-op. |
- AsyncWorkCompleted(); |
-} |
- |
} // namespace extensions |