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

Unified Diff: extensions/browser/api/cast_channel/cast_channel_api.cc

Issue 2913033003: [cast_channel] Move cast_channel related files from //extensions to //components (Closed)
Patch Set: fix buildbot compile errors Created 3 years, 6 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 5e5c4b649daea71af82d82fbe55b572e377aa632..b769c3954ecbd169076a81e85e4f2ff9447ec5a6 100644
--- a/extensions/browser/api/cast_channel/cast_channel_api.cc
+++ b/extensions/browser/api/cast_channel/cast_channel_api.cc
@@ -18,17 +18,18 @@
#include "base/memory/ptr_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/values.h"
+#include "components/cast_channel/cast_message_util.h"
+#include "components/cast_channel/cast_socket.h"
+#include "components/cast_channel/cast_socket_service.h"
+#include "components/cast_channel/cast_socket_service_factory.h"
+#include "components/cast_channel/keep_alive_delegate.h"
+#include "components/cast_channel/logger.h"
+#include "components/cast_channel/proto/cast_channel.pb.h"
+#include "components/cast_channel/proto/logging.pb.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/api/cast_channel/cast_channel_enum_util.h"
#include "extensions/browser/api/cast_channel/cast_message_util.h"
-#include "extensions/browser/api/cast_channel/cast_socket.h"
-#include "extensions/browser/api/cast_channel/cast_socket_service.h"
-#include "extensions/browser/api/cast_channel/cast_socket_service_factory.h"
-#include "extensions/browser/api/cast_channel/keep_alive_delegate.h"
-#include "extensions/browser/api/cast_channel/logger.h"
#include "extensions/browser/event_router.h"
-#include "extensions/common/api/cast_channel/cast_channel.pb.h"
-#include "extensions/common/api/cast_channel/logging.pb.h"
#include "net/base/ip_address.h"
#include "net/base/ip_endpoint.h"
#include "net/base/net_errors.h"
@@ -39,24 +40,25 @@ const int kDefaultConnectTimeoutMillis = 5000; // 5 seconds.
namespace extensions {
-namespace Close = cast_channel::Close;
-namespace OnError = cast_channel::OnError;
-namespace OnMessage = cast_channel::OnMessage;
-namespace Open = cast_channel::Open;
-namespace Send = cast_channel::Send;
-using ::cast_channel::ChannelError;
+namespace Close = api::cast_channel::Close;
+namespace OnError = api::cast_channel::OnError;
+namespace OnMessage = api::cast_channel::OnMessage;
+namespace Open = api::cast_channel::Open;
+namespace Send = api::cast_channel::Send;
+using api::cast_channel::ChannelInfo;
+using api::cast_channel::ConnectInfo;
+using api::cast_channel::ErrorInfo;
+using api::cast_channel::MessageInfo;
+using cast_channel::ChannelError;
using cast_channel::CastDeviceCapability;
using cast_channel::CastMessage;
using cast_channel::CastSocket;
using cast_channel::CastSocketImpl;
using cast_channel::CastTransport;
-using cast_channel::ChannelInfo;
-using cast_channel::ConnectInfo;
-using cast_channel::ErrorInfo;
using cast_channel::KeepAliveDelegate;
using cast_channel::LastErrors;
using cast_channel::Logger;
-using cast_channel::MessageInfo;
+
using content::BrowserThread;
namespace {
@@ -78,16 +80,17 @@ void FillChannelInfo(const CastSocket& socket, ChannelInfo* channel_info) {
channel_info->connect_info.ip_address = ip_endpoint.ToStringWithoutPort();
channel_info->connect_info.port = ip_endpoint.port();
channel_info->connect_info.auth =
- cast_channel::ToChannelAuthType(socket.channel_auth());
- channel_info->ready_state = cast_channel::ToReadyState(socket.ready_state());
+ api::cast_channel::ToChannelAuthType(socket.channel_auth());
+ channel_info->ready_state =
+ api::cast_channel::ToReadyState(socket.ready_state());
channel_info->error_state =
- cast_channel::ToChannelError(socket.error_state());
+ api::cast_channel::ToChannelError(socket.error_state());
channel_info->keep_alive = socket.keep_alive();
channel_info->audio_only = socket.audio_only();
}
// Fills |error_info| from |error_state| and |last_errors|.
-void FillErrorInfo(cast_channel::ChannelError error_state,
+void FillErrorInfo(api::cast_channel::ChannelError error_state,
const LastErrors& last_errors,
ErrorInfo* error_info) {
error_info->error_state = error_state;
@@ -178,7 +181,7 @@ CastChannelAsyncApiFunction::~CastChannelAsyncApiFunction() { }
bool CastChannelAsyncApiFunction::PrePrepare() {
cast_socket_service_ =
- api::cast_channel::CastSocketServiceFactory::GetForBrowserContext(
+ cast_channel::CastSocketServiceFactory::GetForBrowserContext(
browser_context());
DCHECK(cast_socket_service_);
return true;
@@ -192,9 +195,9 @@ void CastChannelAsyncApiFunction::SetResultFromSocket(
const CastSocket& socket) {
ChannelInfo channel_info;
FillChannelInfo(socket, &channel_info);
- cast_channel::ChannelError error =
- cast_channel::ToChannelError(socket.error_state());
- if (error != cast_channel::CHANNEL_ERROR_NONE) {
+ api::cast_channel::ChannelError error =
+ api::cast_channel::ToChannelError(socket.error_state());
+ if (error != api::cast_channel::CHANNEL_ERROR_NONE) {
SetError("Channel socket error = " + base::IntToString(error));
}
SetResultFromChannelInfo(channel_info);
@@ -202,14 +205,15 @@ void CastChannelAsyncApiFunction::SetResultFromSocket(
void CastChannelAsyncApiFunction::SetResultFromError(
int channel_id,
- cast_channel::ChannelError error) {
+ api::cast_channel::ChannelError error) {
ChannelInfo channel_info;
channel_info.channel_id = channel_id;
- channel_info.ready_state = cast_channel::READY_STATE_CLOSED;
+ channel_info.ready_state = api::cast_channel::READY_STATE_CLOSED;
channel_info.error_state = error;
channel_info.connect_info.ip_address = "";
channel_info.connect_info.port = 0;
- channel_info.connect_info.auth = cast_channel::CHANNEL_AUTH_TYPE_SSL_VERIFIED;
+ channel_info.connect_info.auth =
+ api::cast_channel::CHANNEL_AUTH_TYPE_SSL_VERIFIED;
SetResultFromChannelInfo(channel_info);
SetError("Channel error = " + base::IntToString(error));
}
@@ -274,7 +278,8 @@ bool CastChannelOpenFunction::Prepare() {
return false;
}
- channel_auth_ = cast_channel::ToChannelAuthTypeInternal(connect_info.auth);
+ channel_auth_ =
+ api::cast_channel::ToChannelAuthTypeInternal(connect_info.auth);
ip_endpoint_.reset(ParseConnectInfo(connect_info));
return true;
}
@@ -336,7 +341,8 @@ void CastChannelOpenFunction::OnOpen(ChannelError result) {
SetResultFromSocket(*socket);
} else {
// The socket is being destroyed.
- SetResultFromError(new_channel_id_, cast_channel::CHANNEL_ERROR_UNKNOWN);
+ SetResultFromError(new_channel_id_,
+ api::cast_channel::CHANNEL_ERROR_UNKNOWN);
}
AsyncWorkCompleted();
@@ -377,14 +383,14 @@ void CastChannelSendFunction::AsyncWorkStart() {
cast_socket_service_->GetSocket(params_->channel.channel_id);
if (!socket) {
SetResultFromError(params_->channel.channel_id,
- cast_channel::CHANNEL_ERROR_INVALID_CHANNEL_ID);
+ api::cast_channel::CHANNEL_ERROR_INVALID_CHANNEL_ID);
AsyncWorkCompleted();
return;
}
CastMessage message_to_send;
if (!MessageInfoToCastMessage(params_->message, &message_to_send)) {
SetResultFromError(params_->channel.channel_id,
- cast_channel::CHANNEL_ERROR_INVALID_MESSAGE);
+ api::cast_channel::CHANNEL_ERROR_INVALID_MESSAGE);
AsyncWorkCompleted();
return;
}
@@ -398,7 +404,7 @@ void CastChannelSendFunction::OnSend(int result) {
CastSocket* socket = cast_socket_service_->GetSocket(channel_id);
if (result < 0 || !socket) {
SetResultFromError(channel_id,
- cast_channel::CHANNEL_ERROR_SOCKET_ERROR);
+ api::cast_channel::CHANNEL_ERROR_SOCKET_ERROR);
} else {
SetResultFromSocket(*socket);
}
@@ -425,7 +431,7 @@ void CastChannelCloseFunction::AsyncWorkStart() {
cast_socket_service_->GetSocket(params_->channel.channel_id);
if (!socket) {
SetResultFromError(params_->channel.channel_id,
- cast_channel::CHANNEL_ERROR_INVALID_CHANNEL_ID);
+ api::cast_channel::CHANNEL_ERROR_INVALID_CHANNEL_ID);
AsyncWorkCompleted();
} else {
socket->Close(base::Bind(&CastChannelCloseFunction::OnClose, this));
@@ -439,7 +445,7 @@ void CastChannelCloseFunction::OnClose(int result) {
CastSocket* socket = cast_socket_service_->GetSocket(channel_id);
if (result < 0 || !socket) {
SetResultFromError(channel_id,
- cast_channel::CHANNEL_ERROR_SOCKET_ERROR);
+ api::cast_channel::CHANNEL_ERROR_SOCKET_ERROR);
} else {
SetResultFromSocket(*socket);
// This will delete |socket|.
@@ -467,7 +473,7 @@ void CastChannelOpenFunction::CastMessageHandler::OnError(
ChannelInfo channel_info;
FillChannelInfo(*socket_, &channel_info);
- channel_info.error_state = cast_channel::ToChannelError(error_state);
+ channel_info.error_state = api::cast_channel::ToChannelError(error_state);
ErrorInfo error_info;
FillErrorInfo(channel_info.error_state, logger_->GetLastErrors(socket_->id()),
&error_info);
« 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