Commit c84b223b authored by vadimgo's avatar vadimgo Committed by Commit bot

cast channel error cleanup.

BUG=429005

Review URL: https://codereview.chromium.org/690383002

Cr-Commit-Position: refs/heads/master@{#302714}
parent 6c217552
......@@ -6,7 +6,7 @@ var errorEvent = false;
var openCallback = false;
var onClose = function(channel) {
chrome.test.assertLastError('Unknown error.');
chrome.test.assertLastError('Channel socket error = 3');
assertClosedChannelWithError(channel, 'connect_error');
chrome.test.succeed();
}
......@@ -21,7 +21,7 @@ var onError = function(channel, error) {
}
var onOpen = function(channel) {
chrome.test.assertLastError('Unknown error.');
chrome.test.assertLastError('Channel socket error = 3');
openCallback = true;
assertClosedChannelWithError(channel, 'connect_error');
maybeClose(channel);
......
......@@ -172,8 +172,8 @@ void CastChannelAPI::OnMessage(const CastSocket* socket,
CastChannelAPI::~CastChannelAPI() {}
CastChannelAsyncApiFunction::CastChannelAsyncApiFunction()
: manager_(NULL), error_(cast_channel::CHANNEL_ERROR_NONE) { }
CastChannelAsyncApiFunction::CastChannelAsyncApiFunction() : manager_(NULL) {
}
CastChannelAsyncApiFunction::~CastChannelAsyncApiFunction() { }
......@@ -183,7 +183,7 @@ bool CastChannelAsyncApiFunction::PrePrepare() {
}
bool CastChannelAsyncApiFunction::Respond() {
return error_ == cast_channel::CHANNEL_ERROR_NONE;
return GetError().empty();
}
CastSocket* CastChannelAsyncApiFunction::GetSocketOrCompleteWithError(
......@@ -216,7 +216,10 @@ void CastChannelAsyncApiFunction::SetResultFromSocket(
const CastSocket& socket) {
ChannelInfo channel_info;
FillChannelInfo(socket, &channel_info);
error_ = socket.error_state();
ChannelError error = socket.error_state();
if (error != cast_channel::CHANNEL_ERROR_NONE) {
SetError("Channel socket error = " + base::IntToString(error));
}
SetResultFromChannelInfo(channel_info);
}
......@@ -231,7 +234,7 @@ void CastChannelAsyncApiFunction::SetResultFromError(int channel_id,
channel_info.connect_info.port = 0;
channel_info.connect_info.auth = cast_channel::CHANNEL_AUTH_TYPE_SSL;
SetResultFromChannelInfo(channel_info);
error_ = error;
SetError("Channel error = " + base::IntToString(error));
}
CastSocket* CastChannelAsyncApiFunction::GetSocket(int channel_id) {
......
......@@ -129,9 +129,6 @@ class CastChannelAsyncApiFunction : public AsyncApiFunction {
// The API resource manager for CastSockets.
ApiResourceManager<cast_channel::CastSocket>* manager_;
// The result of the function.
cast_channel::ChannelError error_;
};
class CastChannelOpenFunction : public CastChannelAsyncApiFunction {
......
......@@ -502,3 +502,17 @@ IN_PROC_BROWSER_TEST_F(CastChannelAPITest, TestSetAuthorityKeysValid) {
cast_channel_set_authority_keys_function.get(), args, browser());
EXPECT_EQ(error, std::string());
}
// TODO(vadimgo): Win Dbg has a workaround that makes RunExtensionSubtest
// always return true without actually running the test. Remove when fixed.
#if defined(OS_WIN) && !defined(NDEBUG)
#define MAYBE_TestSetAuthorityKeys DISABLED_TestSetAuthorityKeys
#else
#define MAYBE_TestSetAuthorityKeys TestSetAuthorityKeys
#endif
// Test loading extension, opening a channel with ConnectInfo, adding a
// listener, writing, reading, and closing.
IN_PROC_BROWSER_TEST_F(CastChannelAPITest, MAYBE_TestSetAuthorityKeys) {
EXPECT_TRUE(
RunExtensionSubtest("cast_channel/api", "test_authority_keys.html"));
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment