diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-05-03 13:42:47 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-05-15 10:27:51 +0000 |
commit | 8c5c43c7b138c9b4b0bf56d946e61d3bbc111bec (patch) | |
tree | d29d987c4d7b173cf853279b79a51598f104b403 /chromium/jingle | |
parent | 830c9e163d31a9180fadca926b3e1d7dfffb5021 (diff) | |
download | qtwebengine-chromium-8c5c43c7b138c9b4b0bf56d946e61d3bbc111bec.tar.gz |
BASELINE: Update Chromium to 66.0.3359.156
Change-Id: I0c9831ad39911a086b6377b16f995ad75a51e441
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'chromium/jingle')
26 files changed, 183 insertions, 124 deletions
diff --git a/chromium/jingle/BUILD.gn b/chromium/jingle/BUILD.gn index 4b1c0bc1e08..a6785cf60fa 100644 --- a/chromium/jingle/BUILD.gn +++ b/chromium/jingle/BUILD.gn @@ -30,7 +30,7 @@ if (enable_webrtc || !is_android) { "//base", "//base/third_party/dynamic_annotations", "//net", - "//services/network/public/cpp", + "//services/network:network_service", ] configs += [ "//build/config/compiler:no_size_t_to_int_warning" ] @@ -40,7 +40,7 @@ if (enable_webrtc || !is_android) { "glue/chrome_async_socket.cc", "glue/xmpp_client_socket_factory.cc", ] - deps -= [ "//services/network/public/cpp" ] + deps -= [ "//services/network:network_service" ] } } diff --git a/chromium/jingle/glue/DEPS b/chromium/jingle/glue/DEPS index 04ff7b5d9c7..153dc583260 100644 --- a/chromium/jingle/glue/DEPS +++ b/chromium/jingle/glue/DEPS @@ -1,6 +1,7 @@ # Needed by logging_unittest.cc since it tests the overrides. include_rules = [ - "+services/network/public/cpp", + "+services/network/proxy_resolving_client_socket.h", + "+services/network/proxy_resolving_client_socket_factory.h", "+third_party/libjingle_xmpp/task_runner", "+third_party/webrtc", "+third_party/webrtc_overrides", diff --git a/chromium/jingle/glue/chrome_async_socket.cc b/chromium/jingle/glue/chrome_async_socket.cc index f96041c8e61..567e94f29ad 100644 --- a/chromium/jingle/glue/chrome_async_socket.cc +++ b/chromium/jingle/glue/chrome_async_socket.cc @@ -29,7 +29,8 @@ namespace jingle_glue { ChromeAsyncSocket::ChromeAsyncSocket( ResolvingClientSocketFactory* resolving_client_socket_factory, size_t read_buf_size, - size_t write_buf_size) + size_t write_buf_size, + const net::NetworkTrafficAnnotationTag& traffic_annotation) : resolving_client_socket_factory_(resolving_client_socket_factory), state_(STATE_CLOSED), error_(ERROR_NONE), @@ -41,6 +42,7 @@ ChromeAsyncSocket::ChromeAsyncSocket( write_state_(IDLE), write_buf_(new net::IOBufferWithSize(write_buf_size)), write_end_(0U), + traffic_annotation_(traffic_annotation), weak_ptr_factory_(this) { DCHECK(resolving_client_socket_factory_.get()); DCHECK_GT(read_buf_size, 0U); @@ -299,10 +301,10 @@ void ChromeAsyncSocket::DoWrite() { // have received a reply to a message we sent to the server and // before we send the next message. int status = - transport_socket_->Write( - write_buf_.get(), write_end_, - base::Bind(&ChromeAsyncSocket::ProcessWriteDone, - weak_ptr_factory_.GetWeakPtr())); + transport_socket_->Write(write_buf_.get(), write_end_, + base::Bind(&ChromeAsyncSocket::ProcessWriteDone, + weak_ptr_factory_.GetWeakPtr()), + traffic_annotation_); write_state_ = PENDING; if (status != net::ERR_IO_PENDING) { ProcessWriteDone(status); diff --git a/chromium/jingle/glue/chrome_async_socket.h b/chromium/jingle/glue/chrome_async_socket.h index 2677afd2738..e3c13b7f6a9 100644 --- a/chromium/jingle/glue/chrome_async_socket.h +++ b/chromium/jingle/glue/chrome_async_socket.h @@ -19,6 +19,7 @@ #include "base/memory/weak_ptr.h" #include "net/base/completion_callback.h" #include "net/base/net_errors.h" +#include "net/traffic_annotation/network_traffic_annotation.h" #include "third_party/libjingle_xmpp/xmpp/asyncsocket.h" namespace net { @@ -36,7 +37,8 @@ class ChromeAsyncSocket : public buzz::AsyncSocket { ChromeAsyncSocket( ResolvingClientSocketFactory* resolving_client_socket_factory, size_t read_buf_size, - size_t write_buf_size); + size_t write_buf_size, + const net::NetworkTrafficAnnotationTag& traffic_annotation); // Does not raise any signals. ~ChromeAsyncSocket() override; @@ -203,6 +205,11 @@ class ChromeAsyncSocket : public buzz::AsyncSocket { scoped_refptr<net::IOBufferWithSize> write_buf_; size_t write_end_; + // Network traffic annotation for downstream socket write. ChromeAsyncSocket + // is not reused, hence annotation can be added in constructor and used in all + // subsequent writes. + const net::NetworkTrafficAnnotationTag traffic_annotation_; + base::WeakPtrFactory<ChromeAsyncSocket> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(ChromeAsyncSocket); diff --git a/chromium/jingle/glue/chrome_async_socket_unittest.cc b/chromium/jingle/glue/chrome_async_socket_unittest.cc index bc54e6dc47d..77d0659458c 100644 --- a/chromium/jingle/glue/chrome_async_socket_unittest.cc +++ b/chromium/jingle/glue/chrome_async_socket_unittest.cc @@ -26,6 +26,7 @@ #include "net/socket/socket_test_util.h" #include "net/socket/ssl_client_socket.h" #include "net/ssl/ssl_config_service.h" +#include "net/traffic_annotation/network_traffic_annotation_test_helper.h" #include "net/url_request/url_request_context_getter.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/webrtc/rtc_base/ipaddress.h" @@ -182,11 +183,11 @@ class ChromeAsyncSocketTest mock_xmpp_client_socket_factory(new MockXmppClientSocketFactory( mock_client_socket_factory.release(), address_list)); chrome_async_socket_.reset( - new ChromeAsyncSocket(mock_xmpp_client_socket_factory.release(), - 14, 20)), + new ChromeAsyncSocket(mock_xmpp_client_socket_factory.release(), 14, 20, + TRAFFIC_ANNOTATION_FOR_TESTS)), - chrome_async_socket_->SignalConnected.connect( - this, &ChromeAsyncSocketTest::OnConnect); + chrome_async_socket_->SignalConnected.connect( + this, &ChromeAsyncSocketTest::OnConnect); chrome_async_socket_->SignalSSLConnected.connect( this, &ChromeAsyncSocketTest::OnSSLConnect); chrome_async_socket_->SignalClosed.connect( diff --git a/chromium/jingle/glue/fake_ssl_client_socket.cc b/chromium/jingle/glue/fake_ssl_client_socket.cc index 1e0773a1d0b..0ecfde467b5 100644 --- a/chromium/jingle/glue/fake_ssl_client_socket.cc +++ b/chromium/jingle/glue/fake_ssl_client_socket.cc @@ -14,7 +14,7 @@ #include "base/macros.h" #include "net/base/io_buffer.h" #include "net/base/net_errors.h" -#include "net/traffic_annotation/network_traffic_annotation.h" +#include "net/traffic_annotation/network_traffic_annotation_test_helper.h" namespace jingle_glue { @@ -209,7 +209,8 @@ int FakeSSLClientSocket::DoSendClientHello() { int status = transport_socket_->Write( write_buf_.get(), write_buf_->BytesRemaining(), base::Bind(&FakeSSLClientSocket::OnSendClientHelloDone, - base::Unretained(this))); + base::Unretained(this)), + TRAFFIC_ANNOTATION_FOR_TESTS); if (status < net::OK) { return status; } diff --git a/chromium/jingle/glue/xmpp_client_socket_factory.cc b/chromium/jingle/glue/xmpp_client_socket_factory.cc index 317ed1efa61..20b26db205d 100644 --- a/chromium/jingle/glue/xmpp_client_socket_factory.cc +++ b/chromium/jingle/glue/xmpp_client_socket_factory.cc @@ -13,7 +13,7 @@ #include "net/socket/ssl_client_socket.h" #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context_getter.h" -#include "services/network/public/cpp/proxy_resolving_client_socket.h" +#include "services/network/proxy_resolving_client_socket.h" namespace jingle_glue { @@ -24,6 +24,9 @@ XmppClientSocketFactory::XmppClientSocketFactory( bool use_fake_ssl_client_socket) : client_socket_factory_(client_socket_factory), request_context_getter_(request_context_getter), + proxy_resolving_socket_factory_( + nullptr, + request_context_getter->GetURLRequestContext()), ssl_config_(ssl_config), use_fake_ssl_client_socket_(use_fake_ssl_client_socket) { CHECK(client_socket_factory_); @@ -35,10 +38,8 @@ std::unique_ptr<net::StreamSocket> XmppClientSocketFactory::CreateTransportClientSocket( const net::HostPortPair& host_and_port) { // TODO(akalin): Use socket pools. - std::unique_ptr<net::StreamSocket> transport_socket( - new network::ProxyResolvingClientSocket( - nullptr, request_context_getter_, ssl_config_, - GURL("https://" + host_and_port.ToString()))); + auto transport_socket = proxy_resolving_socket_factory_.CreateSocket( + ssl_config_, GURL("https://" + host_and_port.ToString())); return (use_fake_ssl_client_socket_ ? std::unique_ptr<net::StreamSocket>( new FakeSSLClientSocket(std::move(transport_socket))) diff --git a/chromium/jingle/glue/xmpp_client_socket_factory.h b/chromium/jingle/glue/xmpp_client_socket_factory.h index 9615ab4d6ea..029d231f0c7 100644 --- a/chromium/jingle/glue/xmpp_client_socket_factory.h +++ b/chromium/jingle/glue/xmpp_client_socket_factory.h @@ -12,6 +12,11 @@ #include "base/memory/ref_counted.h" #include "jingle/glue/resolving_client_socket_factory.h" #include "net/ssl/ssl_config_service.h" +#include "services/network/proxy_resolving_client_socket_factory.h" + +namespace network { +class ProxyResolvingClientSocketFactory; +} // namespace network namespace net { class ClientSocketFactory; @@ -46,6 +51,10 @@ class XmppClientSocketFactory : public ResolvingClientSocketFactory { private: net::ClientSocketFactory* const client_socket_factory_; scoped_refptr<net::URLRequestContextGetter> request_context_getter_; + // |proxy_resolving_socket_factory_| retains a reference to the raw + // net::URLRequestContext pointer, and thus must not outlive + // |request_context_getter_|. + network::ProxyResolvingClientSocketFactory proxy_resolving_socket_factory_; const net::SSLConfig ssl_config_; const bool use_fake_ssl_client_socket_; diff --git a/chromium/jingle/notifier/base/xmpp_connection.cc b/chromium/jingle/notifier/base/xmpp_connection.cc index 01e4e8ff930..5ef6ad2617b 100644 --- a/chromium/jingle/notifier/base/xmpp_connection.cc +++ b/chromium/jingle/notifier/base/xmpp_connection.cc @@ -27,7 +27,8 @@ namespace { buzz::AsyncSocket* CreateSocket( const buzz::XmppClientSettings& xmpp_client_settings, - const scoped_refptr<net::URLRequestContextGetter>& request_context_getter) { + const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, + const net::NetworkTrafficAnnotationTag& traffic_annotation) { bool use_fake_ssl_client_socket = (xmpp_client_settings.protocol() == cricket::PROTO_SSLTCP); // The default SSLConfig is good enough for us for now. @@ -42,8 +43,9 @@ buzz::AsyncSocket* CreateSocket( ssl_config, request_context_getter, use_fake_ssl_client_socket); - return new jingle_glue::ChromeAsyncSocket(client_socket_factory, - kReadBufSize, kWriteBufSize); + + return new jingle_glue::ChromeAsyncSocket(client_socket_factory, kReadBufSize, + kWriteBufSize, traffic_annotation); } } // namespace @@ -52,7 +54,8 @@ XmppConnection::XmppConnection( const buzz::XmppClientSettings& xmpp_client_settings, const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, Delegate* delegate, - buzz::PreXmppAuth* pre_xmpp_auth) + buzz::PreXmppAuth* pre_xmpp_auth, + const net::NetworkTrafficAnnotationTag& traffic_annotation) : task_pump_(new jingle_glue::TaskPump()), on_connect_called_(false), delegate_(delegate) { @@ -67,11 +70,11 @@ XmppConnection::XmppConnection( weak_xmpp_client->SignalLogOutput.connect( this, &XmppConnection::OnOutputLog); const char kLanguage[] = "en"; - buzz::XmppReturnStatus connect_status = - weak_xmpp_client->Connect(xmpp_client_settings, kLanguage, - CreateSocket(xmpp_client_settings, - request_context_getter), - pre_xmpp_auth); + buzz::XmppReturnStatus connect_status = weak_xmpp_client->Connect( + xmpp_client_settings, kLanguage, + CreateSocket(xmpp_client_settings, request_context_getter, + traffic_annotation), + pre_xmpp_auth); // buzz::XmppClient::Connect() should never fail. DCHECK_EQ(connect_status, buzz::XMPP_RETURN_OK); weak_xmpp_client->Start(); diff --git a/chromium/jingle/notifier/base/xmpp_connection.h b/chromium/jingle/notifier/base/xmpp_connection.h index 9924429eb46..78189c7f171 100644 --- a/chromium/jingle/notifier/base/xmpp_connection.h +++ b/chromium/jingle/notifier/base/xmpp_connection.h @@ -14,6 +14,7 @@ #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "base/sequence_checker.h" +#include "net/traffic_annotation/network_traffic_annotation.h" #include "net/url_request/url_request_context_getter.h" #include "third_party/libjingle_xmpp/xmpp/xmppengine.h" #include "third_party/webrtc/rtc_base/sigslot.h" @@ -67,11 +68,12 @@ class XmppConnection : public sigslot::has_slots<> { // NULL. Takes ownership of |pre_xmpp_auth|, which may be NULL. // // TODO(akalin): Avoid the need for |pre_xmpp_auth|. - XmppConnection(const buzz::XmppClientSettings& xmpp_client_settings, - const scoped_refptr<net::URLRequestContextGetter>& - request_context_getter, - Delegate* delegate, - buzz::PreXmppAuth* pre_xmpp_auth); + XmppConnection( + const buzz::XmppClientSettings& xmpp_client_settings, + const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, + Delegate* delegate, + buzz::PreXmppAuth* pre_xmpp_auth, + const net::NetworkTrafficAnnotationTag& traffic_annotation); // Invalidates any weak pointers passed to the delegate by // OnConnect(), but does not trigger a call to the delegate's diff --git a/chromium/jingle/notifier/base/xmpp_connection_unittest.cc b/chromium/jingle/notifier/base/xmpp_connection_unittest.cc index aabd6ae7ee0..0ce37ea415c 100644 --- a/chromium/jingle/notifier/base/xmpp_connection_unittest.cc +++ b/chromium/jingle/notifier/base/xmpp_connection_unittest.cc @@ -17,6 +17,7 @@ #include "jingle/glue/task_pump.h" #include "jingle/notifier/base/weak_xmpp_client.h" #include "net/cert/cert_verifier.h" +#include "net/traffic_annotation/network_traffic_annotation_test_helper.h" #include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_test_util.h" #include "testing/gmock/include/gmock/gmock.h" @@ -101,9 +102,9 @@ class XmppConnectionTest : public testing::Test { }; TEST_F(XmppConnectionTest, CreateDestroy) { - XmppConnection xmpp_connection(buzz::XmppClientSettings(), - url_request_context_getter_, - &mock_xmpp_connection_delegate_, NULL); + XmppConnection xmpp_connection( + buzz::XmppClientSettings(), url_request_context_getter_, + &mock_xmpp_connection_delegate_, NULL, TRAFFIC_ANNOTATION_FOR_TESTS); } TEST_F(XmppConnectionTest, ImmediateFailure) { @@ -113,9 +114,9 @@ TEST_F(XmppConnectionTest, ImmediateFailure) { EXPECT_CALL(mock_xmpp_connection_delegate_, OnError(buzz::XmppEngine::ERROR_NONE, 0, NULL)); - XmppConnection xmpp_connection(buzz::XmppClientSettings(), - url_request_context_getter_, - &mock_xmpp_connection_delegate_, NULL); + XmppConnection xmpp_connection( + buzz::XmppClientSettings(), url_request_context_getter_, + &mock_xmpp_connection_delegate_, NULL, TRAFFIC_ANNOTATION_FOR_TESTS); // We need to do this *before* |xmpp_connection| gets destroyed or // our delegate won't be called. @@ -134,7 +135,8 @@ TEST_F(XmppConnectionTest, PreAuthFailure) { XmppConnection xmpp_connection( buzz::XmppClientSettings(), url_request_context_getter_, - &mock_xmpp_connection_delegate_, mock_pre_xmpp_auth_.release()); + &mock_xmpp_connection_delegate_, mock_pre_xmpp_auth_.release(), + TRAFFIC_ANNOTATION_FOR_TESTS); // We need to do this *before* |xmpp_connection| gets destroyed or // our delegate won't be called. @@ -153,7 +155,8 @@ TEST_F(XmppConnectionTest, FailureAfterPreAuth) { XmppConnection xmpp_connection( buzz::XmppClientSettings(), url_request_context_getter_, - &mock_xmpp_connection_delegate_, mock_pre_xmpp_auth_.release()); + &mock_xmpp_connection_delegate_, mock_pre_xmpp_auth_.release(), + TRAFFIC_ANNOTATION_FOR_TESTS); // We need to do this *before* |xmpp_connection| gets destroyed or // our delegate won't be called. @@ -164,9 +167,9 @@ TEST_F(XmppConnectionTest, RaisedError) { EXPECT_CALL(mock_xmpp_connection_delegate_, OnError(buzz::XmppEngine::ERROR_NONE, 0, NULL)); - XmppConnection xmpp_connection(buzz::XmppClientSettings(), - url_request_context_getter_, - &mock_xmpp_connection_delegate_, NULL); + XmppConnection xmpp_connection( + buzz::XmppClientSettings(), url_request_context_getter_, + &mock_xmpp_connection_delegate_, NULL, TRAFFIC_ANNOTATION_FOR_TESTS); xmpp_connection.weak_xmpp_client_-> SignalStateChange(buzz::XmppEngine::STATE_CLOSED); @@ -178,9 +181,9 @@ TEST_F(XmppConnectionTest, Connect) { WillOnce(SaveArg<0>(&weak_ptr)); { - XmppConnection xmpp_connection(buzz::XmppClientSettings(), - url_request_context_getter_, - &mock_xmpp_connection_delegate_, NULL); + XmppConnection xmpp_connection( + buzz::XmppClientSettings(), url_request_context_getter_, + &mock_xmpp_connection_delegate_, NULL, TRAFFIC_ANNOTATION_FOR_TESTS); xmpp_connection.weak_xmpp_client_-> SignalStateChange(buzz::XmppEngine::STATE_OPEN); @@ -196,9 +199,9 @@ TEST_F(XmppConnectionTest, MultipleConnect) { EXPECT_CALL(mock_xmpp_connection_delegate_, OnConnect(_)). WillOnce(SaveArg<0>(&weak_ptr)); - XmppConnection xmpp_connection(buzz::XmppClientSettings(), - url_request_context_getter_, - &mock_xmpp_connection_delegate_, NULL); + XmppConnection xmpp_connection( + buzz::XmppClientSettings(), url_request_context_getter_, + &mock_xmpp_connection_delegate_, NULL, TRAFFIC_ANNOTATION_FOR_TESTS); xmpp_connection.weak_xmpp_client_-> SignalStateChange(buzz::XmppEngine::STATE_OPEN); @@ -218,9 +221,9 @@ TEST_F(XmppConnectionTest, ConnectThenError) { EXPECT_CALL(mock_xmpp_connection_delegate_, OnError(buzz::XmppEngine::ERROR_NONE, 0, NULL)); - XmppConnection xmpp_connection(buzz::XmppClientSettings(), - url_request_context_getter_, - &mock_xmpp_connection_delegate_, NULL); + XmppConnection xmpp_connection( + buzz::XmppClientSettings(), url_request_context_getter_, + &mock_xmpp_connection_delegate_, NULL, TRAFFIC_ANNOTATION_FOR_TESTS); xmpp_connection.weak_xmpp_client_-> SignalStateChange(buzz::XmppEngine::STATE_OPEN); @@ -235,9 +238,9 @@ TEST_F(XmppConnectionTest, ConnectThenError) { // should still not run any more tasks. TEST_F(XmppConnectionTest, TasksDontRunAfterXmppConnectionDestructor) { { - XmppConnection xmpp_connection(buzz::XmppClientSettings(), - url_request_context_getter_, - &mock_xmpp_connection_delegate_, NULL); + XmppConnection xmpp_connection( + buzz::XmppClientSettings(), url_request_context_getter_, + &mock_xmpp_connection_delegate_, NULL, TRAFFIC_ANNOTATION_FOR_TESTS); jingle_glue::MockTask* task = new jingle_glue::MockTask(xmpp_connection.task_pump_.get()); diff --git a/chromium/jingle/notifier/communicator/login.cc b/chromium/jingle/notifier/communicator/login.cc index 986d0aa9435..7e10c4fda5b 100644 --- a/chromium/jingle/notifier/communicator/login.cc +++ b/chromium/jingle/notifier/communicator/login.cc @@ -25,19 +25,21 @@ namespace notifier { Login::Delegate::~Delegate() {} -Login::Login(Delegate* delegate, - const buzz::XmppClientSettings& user_settings, - const scoped_refptr<net::URLRequestContextGetter>& - request_context_getter, - const ServerList& servers, - bool try_ssltcp_first, - const std::string& auth_mechanism) +Login::Login( + Delegate* delegate, + const buzz::XmppClientSettings& user_settings, + const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, + const ServerList& servers, + bool try_ssltcp_first, + const std::string& auth_mechanism, + const net::NetworkTrafficAnnotationTag& traffic_annotation) : delegate_(delegate), login_settings_(user_settings, request_context_getter, servers, try_ssltcp_first, - auth_mechanism) { + auth_mechanism, + traffic_annotation) { net::NetworkChangeNotifier::AddNetworkChangeObserver(this); // TODO(akalin): Add as DNSObserver once bug 130610 is fixed. ResetReconnectState(); diff --git a/chromium/jingle/notifier/communicator/login.h b/chromium/jingle/notifier/communicator/login.h index 7ce68c82239..d57de09ad68 100644 --- a/chromium/jingle/notifier/communicator/login.h +++ b/chromium/jingle/notifier/communicator/login.h @@ -18,6 +18,7 @@ #include "jingle/notifier/communicator/login_settings.h" #include "jingle/notifier/communicator/single_login_attempt.h" #include "net/base/network_change_notifier.h" +#include "net/traffic_annotation/network_traffic_annotation.h" #include "third_party/libjingle_xmpp/xmpp/xmppengine.h" namespace buzz { @@ -64,13 +65,14 @@ class Login : public net::NetworkChangeNotifier::NetworkChangeObserver, }; // Does not take ownership of |delegate|, which must not be NULL. - Login(Delegate* delegate, - const buzz::XmppClientSettings& user_settings, - const scoped_refptr<net::URLRequestContextGetter>& - request_context_getter, - const ServerList& servers, - bool try_ssltcp_first, - const std::string& auth_mechanism); + Login( + Delegate* delegate, + const buzz::XmppClientSettings& user_settings, + const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, + const ServerList& servers, + bool try_ssltcp_first, + const std::string& auth_mechanism, + const net::NetworkTrafficAnnotationTag& traffic_annotation); ~Login() override; // Starts connecting (or forces a reconnection if we're backed off). diff --git a/chromium/jingle/notifier/communicator/login_settings.cc b/chromium/jingle/notifier/communicator/login_settings.cc index 8aa518f57f7..66272abad9b 100644 --- a/chromium/jingle/notifier/communicator/login_settings.cc +++ b/chromium/jingle/notifier/communicator/login_settings.cc @@ -13,17 +13,19 @@ namespace notifier { -LoginSettings::LoginSettings(const buzz::XmppClientSettings& user_settings, - const scoped_refptr<net::URLRequestContextGetter>& - request_context_getter, - const ServerList& default_servers, - bool try_ssltcp_first, - const std::string& auth_mechanism) +LoginSettings::LoginSettings( + const buzz::XmppClientSettings& user_settings, + const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, + const ServerList& default_servers, + bool try_ssltcp_first, + const std::string& auth_mechanism, + const net::NetworkTrafficAnnotationTag& traffic_annotation) : user_settings_(user_settings), request_context_getter_(request_context_getter), default_servers_(default_servers), try_ssltcp_first_(try_ssltcp_first), - auth_mechanism_(auth_mechanism) { + auth_mechanism_(auth_mechanism), + traffic_annotation_(traffic_annotation) { DCHECK_GT(default_servers_.size(), 0u); } diff --git a/chromium/jingle/notifier/communicator/login_settings.h b/chromium/jingle/notifier/communicator/login_settings.h index ae81e7f5b31..0c8e65140b9 100644 --- a/chromium/jingle/notifier/communicator/login_settings.h +++ b/chromium/jingle/notifier/communicator/login_settings.h @@ -9,6 +9,7 @@ #include "base/memory/ref_counted.h" #include "base/time/time.h" #include "jingle/notifier/base/server_information.h" +#include "net/traffic_annotation/network_traffic_annotation.h" #include "net/url_request/url_request_context_getter.h" #include "third_party/libjingle_xmpp/xmpp/xmppclientsettings.h" @@ -16,12 +17,13 @@ namespace notifier { class LoginSettings { public: - LoginSettings(const buzz::XmppClientSettings& user_settings, - const scoped_refptr<net::URLRequestContextGetter>& - request_context_getter, - const ServerList& default_servers, - bool try_ssltcp_first, - const std::string& auth_mechanism); + LoginSettings( + const buzz::XmppClientSettings& user_settings, + const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, + const ServerList& default_servers, + bool try_ssltcp_first, + const std::string& auth_mechanism, + const net::NetworkTrafficAnnotationTag& traffic_annotation); LoginSettings(const LoginSettings& other); @@ -49,6 +51,10 @@ class LoginSettings { ServerList GetServers() const; + const net::NetworkTrafficAnnotationTag traffic_annotation() const { + return traffic_annotation_; + } + // The redirect server will eventually expire. void SetRedirectServer(const ServerInformation& redirect_server); @@ -64,6 +70,7 @@ class LoginSettings { ServerList default_servers_; bool try_ssltcp_first_; std::string auth_mechanism_; + const net::NetworkTrafficAnnotationTag traffic_annotation_; // Used to handle redirects ServerInformation redirect_server_; diff --git a/chromium/jingle/notifier/communicator/login_settings_unittest.cc b/chromium/jingle/notifier/communicator/login_settings_unittest.cc index fb0034f4fab..2b75d3d2506 100644 --- a/chromium/jingle/notifier/communicator/login_settings_unittest.cc +++ b/chromium/jingle/notifier/communicator/login_settings_unittest.cc @@ -6,6 +6,7 @@ #include <cstddef> +#include "net/traffic_annotation/network_traffic_annotation_test_helper.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/libjingle_xmpp/xmpp/xmppclientsettings.h" @@ -28,25 +29,22 @@ class LoginSettingsTest : public ::testing::Test { }; TEST_F(LoginSettingsTest, Basic) { - const LoginSettings login_settings(buzz::XmppClientSettings(), - NULL, - servers_, - false /* try_ssltcp_first */, - kAuthMechanism); + const LoginSettings login_settings( + buzz::XmppClientSettings(), NULL, servers_, false /* try_ssltcp_first */, + kAuthMechanism, TRAFFIC_ANNOTATION_FOR_TESTS); EXPECT_EQ(base::Time(), login_settings.GetRedirectExpirationForTest()); const ServerList& servers = login_settings.GetServers(); ASSERT_EQ(servers_.size(), servers.size()); for (size_t i = 0; i < servers.size(); ++i) { EXPECT_TRUE(servers[i].Equals(servers_[i])); } + EXPECT_EQ(TRAFFIC_ANNOTATION_FOR_TESTS, login_settings.traffic_annotation()); } TEST_F(LoginSettingsTest, Redirect) { - LoginSettings login_settings(buzz::XmppClientSettings(), - NULL, - servers_, - false /* try_ssltcp_first */, - kAuthMechanism); + LoginSettings login_settings(buzz::XmppClientSettings(), NULL, servers_, + false /* try_ssltcp_first */, kAuthMechanism, + TRAFFIC_ANNOTATION_FOR_TESTS); const ServerInformation redirect_server( net::HostPortPair("redirect.com", 200), SUPPORTS_SSLTCP); diff --git a/chromium/jingle/notifier/communicator/single_login_attempt.cc b/chromium/jingle/notifier/communicator/single_login_attempt.cc index a8d0732dbd5..dd713fd5243 100644 --- a/chromium/jingle/notifier/communicator/single_login_attempt.cc +++ b/chromium/jingle/notifier/communicator/single_login_attempt.cc @@ -174,11 +174,9 @@ void SingleLoginAttempt::TryConnect( jid.Str(), client_settings.auth_token(), client_settings.token_service(), login_settings_.auth_mechanism()); - xmpp_connection_.reset( - new XmppConnection(client_settings, - login_settings_.request_context_getter(), - this, - pre_xmpp_auth)); + xmpp_connection_.reset(new XmppConnection( + client_settings, login_settings_.request_context_getter(), this, + pre_xmpp_auth, login_settings_.traffic_annotation())); } } // namespace notifier diff --git a/chromium/jingle/notifier/communicator/single_login_attempt_unittest.cc b/chromium/jingle/notifier/communicator/single_login_attempt_unittest.cc index f200d882e80..0608e559db3 100644 --- a/chromium/jingle/notifier/communicator/single_login_attempt_unittest.cc +++ b/chromium/jingle/notifier/communicator/single_login_attempt_unittest.cc @@ -15,6 +15,7 @@ #include "jingle/notifier/base/fake_base_task.h" #include "jingle/notifier/communicator/login_settings.h" #include "net/dns/mock_host_resolver.h" +#include "net/traffic_annotation/network_traffic_annotation_test_helper.h" #include "net/url_request/url_request_test_util.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/libjingle_xmpp/xmllite/xmlelement.h" @@ -91,7 +92,8 @@ class SingleLoginAttemptTest : public ::testing::Test { ServerInformation(net::HostPortPair("example.com", 100), SUPPORTS_SSLTCP)), false /* try_ssltcp_first */, - "auth_mechanism"), + "auth_mechanism", + TRAFFIC_ANNOTATION_FOR_TESTS), attempt_(new SingleLoginAttempt(login_settings_, &fake_delegate_)) {} void TearDown() override { base::RunLoop().RunUntilIdle(); } diff --git a/chromium/jingle/notifier/listener/fake_push_client.cc b/chromium/jingle/notifier/listener/fake_push_client.cc index 7225408ced7..2918c27cd64 100644 --- a/chromium/jingle/notifier/listener/fake_push_client.cc +++ b/chromium/jingle/notifier/listener/fake_push_client.cc @@ -26,7 +26,9 @@ void FakePushClient::UpdateSubscriptions( } void FakePushClient::UpdateCredentials( - const std::string& email, const std::string& token) { + const std::string& email, + const std::string& token, + const net::NetworkTrafficAnnotationTag& traffic_annotation) { email_ = email; token_ = token; } diff --git a/chromium/jingle/notifier/listener/fake_push_client.h b/chromium/jingle/notifier/listener/fake_push_client.h index 8b36ea63f90..7b45be527eb 100644 --- a/chromium/jingle/notifier/listener/fake_push_client.h +++ b/chromium/jingle/notifier/listener/fake_push_client.h @@ -25,8 +25,10 @@ class FakePushClient : public PushClient { void AddObserver(PushClientObserver* observer) override; void RemoveObserver(PushClientObserver* observer) override; void UpdateSubscriptions(const SubscriptionList& subscriptions) override; - void UpdateCredentials(const std::string& email, - const std::string& token) override; + void UpdateCredentials( + const std::string& email, + const std::string& token, + const net::NetworkTrafficAnnotationTag& traffic_annotation) override; void SendNotification(const Notification& notification) override; void SendPing() override; diff --git a/chromium/jingle/notifier/listener/non_blocking_push_client.cc b/chromium/jingle/notifier/listener/non_blocking_push_client.cc index 4b7309d1373..88c59b42503 100644 --- a/chromium/jingle/notifier/listener/non_blocking_push_client.cc +++ b/chromium/jingle/notifier/listener/non_blocking_push_client.cc @@ -37,7 +37,10 @@ class NonBlockingPushClient::Core void DestroyOnDelegateThread(); void UpdateSubscriptions(const SubscriptionList& subscriptions); - void UpdateCredentials(const std::string& email, const std::string& token); + void UpdateCredentials( + const std::string& email, + const std::string& token, + const net::NetworkTrafficAnnotationTag& traffic_annotation); void SendNotification(const Notification& data); void SendPing(); @@ -98,10 +101,12 @@ void NonBlockingPushClient::Core::UpdateSubscriptions( } void NonBlockingPushClient::Core::UpdateCredentials( - const std::string& email, const std::string& token) { + const std::string& email, + const std::string& token, + const net::NetworkTrafficAnnotationTag& traffic_annotation) { DCHECK(delegate_task_runner_->BelongsToCurrentThread()); DCHECK(delegate_push_client_.get()); - delegate_push_client_->UpdateCredentials(email, token); + delegate_push_client_->UpdateCredentials(email, token, traffic_annotation); } void NonBlockingPushClient::Core::SendNotification( @@ -192,12 +197,13 @@ void NonBlockingPushClient::UpdateSubscriptions( } void NonBlockingPushClient::UpdateCredentials( - const std::string& email, const std::string& token) { + const std::string& email, + const std::string& token, + const net::NetworkTrafficAnnotationTag& traffic_annotation) { DCHECK(thread_checker_.CalledOnValidThread()); delegate_task_runner_->PostTask( - FROM_HERE, - base::Bind(&NonBlockingPushClient::Core::UpdateCredentials, - core_, email, token)); + FROM_HERE, base::Bind(&NonBlockingPushClient::Core::UpdateCredentials, + core_, email, token, traffic_annotation)); } void NonBlockingPushClient::SendNotification( diff --git a/chromium/jingle/notifier/listener/non_blocking_push_client.h b/chromium/jingle/notifier/listener/non_blocking_push_client.h index 555572a95a5..29a25beaf48 100644 --- a/chromium/jingle/notifier/listener/non_blocking_push_client.h +++ b/chromium/jingle/notifier/listener/non_blocking_push_client.h @@ -46,8 +46,10 @@ class NonBlockingPushClient : public PushClient { void AddObserver(PushClientObserver* observer) override; void RemoveObserver(PushClientObserver* observer) override; void UpdateSubscriptions(const SubscriptionList& subscriptions) override; - void UpdateCredentials(const std::string& email, - const std::string& token) override; + void UpdateCredentials( + const std::string& email, + const std::string& token, + const net::NetworkTrafficAnnotationTag& traffic_annotation) override; void SendNotification(const Notification& notification) override; void SendPing() override; diff --git a/chromium/jingle/notifier/listener/non_blocking_push_client_unittest.cc b/chromium/jingle/notifier/listener/non_blocking_push_client_unittest.cc index f7826d3b5f8..1fdf3a59763 100644 --- a/chromium/jingle/notifier/listener/non_blocking_push_client_unittest.cc +++ b/chromium/jingle/notifier/listener/non_blocking_push_client_unittest.cc @@ -15,6 +15,7 @@ #include "jingle/notifier/listener/fake_push_client.h" #include "jingle/notifier/listener/fake_push_client_observer.h" #include "jingle/notifier/listener/push_client_observer.h" +#include "net/traffic_annotation/network_traffic_annotation_test_helper.h" #include "net/url_request/url_request_test_util.h" #include "testing/gtest/include/gtest/gtest.h" @@ -84,7 +85,7 @@ TEST_F(NonBlockingPushClientTest, UpdateCredentials) { const char kEmail[] = "foo@bar.com"; const char kToken[] = "baz"; - push_client_->UpdateCredentials(kEmail, kToken); + push_client_->UpdateCredentials(kEmail, kToken, TRAFFIC_ANNOTATION_FOR_TESTS); EXPECT_TRUE(fake_push_client_->email().empty()); EXPECT_TRUE(fake_push_client_->token().empty()); base::RunLoop().RunUntilIdle(); diff --git a/chromium/jingle/notifier/listener/push_client.h b/chromium/jingle/notifier/listener/push_client.h index 1b831b7c2e2..db257b3702e 100644 --- a/chromium/jingle/notifier/listener/push_client.h +++ b/chromium/jingle/notifier/listener/push_client.h @@ -9,6 +9,7 @@ #include <string> #include "jingle/notifier/listener/notification_defines.h" +#include "net/traffic_annotation/network_traffic_annotation.h" namespace notifier { @@ -46,7 +47,9 @@ class PushClient { // already connected, the next connection attempt will use the given // credentials. virtual void UpdateCredentials( - const std::string& email, const std::string& token) = 0; + const std::string& email, + const std::string& token, + const net::NetworkTrafficAnnotationTag& traffic_annotation) = 0; // Sends a notification (with no reliability guarantees). virtual void SendNotification(const Notification& notification) = 0; diff --git a/chromium/jingle/notifier/listener/xmpp_push_client.cc b/chromium/jingle/notifier/listener/xmpp_push_client.cc index 0fe9c88cf8a..5c51fe2a715 100644 --- a/chromium/jingle/notifier/listener/xmpp_push_client.cc +++ b/chromium/jingle/notifier/listener/xmpp_push_client.cc @@ -117,7 +117,9 @@ void XmppPushClient::UpdateSubscriptions( } void XmppPushClient::UpdateCredentials( - const std::string& email, const std::string& token) { + const std::string& email, + const std::string& token, + const net::NetworkTrafficAnnotationTag& traffic_annotation) { DCHECK(thread_checker_.CalledOnValidThread()); DVLOG(1) << "Push: Updating credentials for " << email; xmpp_settings_ = MakeXmppClientSettings(notifier_options_, email, token); @@ -126,12 +128,10 @@ void XmppPushClient::UpdateCredentials( } else { DVLOG(1) << "Push: Starting XMPP connection"; base_task_.reset(); - login_.reset(new notifier::Login(this, - xmpp_settings_, - notifier_options_.request_context_getter, - GetServerList(notifier_options_), - notifier_options_.try_ssltcp_first, - notifier_options_.auth_mechanism)); + login_.reset(new notifier::Login( + this, xmpp_settings_, notifier_options_.request_context_getter, + GetServerList(notifier_options_), notifier_options_.try_ssltcp_first, + notifier_options_.auth_mechanism, traffic_annotation)); login_->StartConnection(); } } diff --git a/chromium/jingle/notifier/listener/xmpp_push_client.h b/chromium/jingle/notifier/listener/xmpp_push_client.h index 6472a08380a..742d4faefca 100644 --- a/chromium/jingle/notifier/listener/xmpp_push_client.h +++ b/chromium/jingle/notifier/listener/xmpp_push_client.h @@ -47,8 +47,10 @@ class XmppPushClient : void AddObserver(PushClientObserver* observer) override; void RemoveObserver(PushClientObserver* observer) override; void UpdateSubscriptions(const SubscriptionList& subscriptions) override; - void UpdateCredentials(const std::string& email, - const std::string& token) override; + void UpdateCredentials( + const std::string& email, + const std::string& token, + const net::NetworkTrafficAnnotationTag& traffic_annotation) override; void SendNotification(const Notification& notification) override; void SendPing() override; |