| OLD | NEW |
| 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_socket.h" | 5 #include "extensions/browser/api/cast_channel/cast_socket.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/location.h" |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 14 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 15 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 16 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
| 18 #include "base/single_thread_task_runner.h" |
| 17 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
| 18 #include "base/sys_byteorder.h" | 20 #include "base/sys_byteorder.h" |
| 19 #include "base/test/simple_test_clock.h" | 21 #include "base/test/simple_test_clock.h" |
| 22 #include "base/threading/thread_task_runner_handle.h" |
| 20 #include "base/timer/mock_timer.h" | 23 #include "base/timer/mock_timer.h" |
| 21 #include "extensions/browser/api/cast_channel/cast_auth_util.h" | 24 #include "extensions/browser/api/cast_channel/cast_auth_util.h" |
| 22 #include "extensions/browser/api/cast_channel/cast_framer.h" | 25 #include "extensions/browser/api/cast_channel/cast_framer.h" |
| 23 #include "extensions/browser/api/cast_channel/cast_message_util.h" | 26 #include "extensions/browser/api/cast_channel/cast_message_util.h" |
| 24 #include "extensions/browser/api/cast_channel/cast_test_util.h" | 27 #include "extensions/browser/api/cast_channel/cast_test_util.h" |
| 25 #include "extensions/browser/api/cast_channel/cast_transport.h" | 28 #include "extensions/browser/api/cast_channel/cast_transport.h" |
| 26 #include "extensions/browser/api/cast_channel/logger.h" | 29 #include "extensions/browser/api/cast_channel/logger.h" |
| 27 #include "extensions/common/api/cast_channel/cast_channel.pb.h" | 30 #include "extensions/common/api/cast_channel/cast_channel.pb.h" |
| 28 #include "net/base/address_list.h" | 31 #include "net/base/address_list.h" |
| 29 #include "net/base/net_errors.h" | 32 #include "net/base/net_errors.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 } | 104 } |
| 102 | 105 |
| 103 virtual int Connect(const net::CompletionCallback& callback) { | 106 virtual int Connect(const net::CompletionCallback& callback) { |
| 104 if (do_nothing_) { | 107 if (do_nothing_) { |
| 105 // Stall the I/O event loop. | 108 // Stall the I/O event loop. |
| 106 return net::ERR_IO_PENDING; | 109 return net::ERR_IO_PENDING; |
| 107 } | 110 } |
| 108 | 111 |
| 109 if (connect_data_.mode == net::ASYNC) { | 112 if (connect_data_.mode == net::ASYNC) { |
| 110 CHECK_NE(connect_data_.result, net::ERR_IO_PENDING); | 113 CHECK_NE(connect_data_.result, net::ERR_IO_PENDING); |
| 111 base::MessageLoop::current()->PostTask( | 114 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 112 FROM_HERE, | 115 FROM_HERE, base::Bind(callback, connect_data_.result)); |
| 113 base::Bind(callback, connect_data_.result)); | |
| 114 return net::ERR_IO_PENDING; | 116 return net::ERR_IO_PENDING; |
| 115 } else { | 117 } else { |
| 116 return connect_data_.result; | 118 return connect_data_.result; |
| 117 } | 119 } |
| 118 } | 120 } |
| 119 | 121 |
| 120 virtual bool SetKeepAlive(bool enable, int delay) { | 122 virtual bool SetKeepAlive(bool enable, int delay) { |
| 121 // Always return true in tests | 123 // Always return true in tests |
| 122 return true; | 124 return true; |
| 123 } | 125 } |
| (...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 logger_, cast_channel::CastDeviceCapability::VIDEO_OUT); | 888 logger_, cast_channel::CastDeviceCapability::VIDEO_OUT); |
| 887 EXPECT_FALSE(socket_->audio_only()); | 889 EXPECT_FALSE(socket_->audio_only()); |
| 888 EXPECT_TRUE(socket_->TestVerifyChannelPolicyNone()); | 890 EXPECT_TRUE(socket_->TestVerifyChannelPolicyNone()); |
| 889 EXPECT_FALSE(socket_->audio_only()); | 891 EXPECT_FALSE(socket_->audio_only()); |
| 890 EXPECT_FALSE(socket_->TestVerifyChannelPolicyAudioOnly()); | 892 EXPECT_FALSE(socket_->TestVerifyChannelPolicyAudioOnly()); |
| 891 EXPECT_TRUE(socket_->audio_only()); | 893 EXPECT_TRUE(socket_->audio_only()); |
| 892 } | 894 } |
| 893 } // namespace cast_channel | 895 } // namespace cast_channel |
| 894 } // namespace api | 896 } // namespace api |
| 895 } // namespace extensions | 897 } // namespace extensions |
| OLD | NEW |