Skip to content

Commit

Permalink
Changes needed to roll libjingle r141 to chrome.
Browse files Browse the repository at this point in the history
1. Setting ice username and password for P2PTransportChannel.
2. Updating XMPP Auth cookie with Auth Token

Review URL: https://chromiumcodereview.appspot.com/10382003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138334 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
sergeyu@chromium.org committed May 22, 2012
1 parent e101fc3 commit 71a0c6b
Show file tree
Hide file tree
Showing 27 changed files with 126 additions and 79 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ vars = {
"nacl_toolchain_revision": "8612",
"pnacl_toolchain_revision": "8612",

"libjingle_revision": "136",
"libjingle_revision": "145",
"libphonenumber_revision": "425",
"libvpx_revision": "134182",
"lss_revision": "9",
Expand Down
1 change: 0 additions & 1 deletion content/renderer/media/media_stream_dependency_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "content/renderer/p2p/ipc_socket_factory.h"
#include "content/renderer/p2p/port_allocator.h"
#include "jingle/glue/thread_wrapper.h"
#include "third_party/libjingle/source/talk/app/webrtc/peerconnection.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"

class P2PPortAllocatorFactory : public webrtc::PortAllocatorFactoryInterface {
Expand Down
2 changes: 1 addition & 1 deletion content/renderer/media/media_stream_dependency_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "content/common/content_export.h"
#include "third_party/libjingle/source/talk/app/webrtc/peerconnection.h"
#include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h"
#include "webkit/glue/p2p_transport.h"

namespace content {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,12 @@ class MockSessionDescription : public SessionDescriptionInterface {
NOTIMPLEMENTED();
return 0;
}
virtual const IceCandidateColletion* candidates(
virtual const IceCandidateCollection* candidates(
size_t mediasection_index) const OVERRIDE {
NOTIMPLEMENTED();
return NULL;
}

virtual bool ToString(std::string* out) const OVERRIDE {
*out = sdp_;
return true;
Expand Down
2 changes: 1 addition & 1 deletion content/renderer/media/mock_peer_connection_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "third_party/libjingle/source/talk/app/webrtc/peerconnection.h"
#include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h"

class MockMediaStreamDependencyFactory;

Expand Down
2 changes: 1 addition & 1 deletion content/renderer/media/peer_connection_handler_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "base/message_loop_proxy.h"
#include "content/common/content_export.h"
#include "third_party/libjingle/source/talk/app/webrtc/mediastream.h"
#include "third_party/libjingle/source/talk/app/webrtc/peerconnection.h"
#include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStreamDescriptor.h"

class MediaStreamDependencyFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "content/renderer/media/mock_peer_connection_impl.h"
#include "content/renderer/media/peer_connection_handler_jsep.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/libjingle/source/talk/app/webrtc/peerconnection.h"
#include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebICECandidateDescriptor.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebICEOptions.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaHints.h"
Expand Down
2 changes: 1 addition & 1 deletion content/renderer/media/peer_connection_handler_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "content/renderer/media/rtc_video_decoder.h"
#include "jingle/glue/thread_wrapper.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/libjingle/source/talk/app/webrtc/peerconnection.h"
#include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStreamDescriptor.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStreamSource.h"

Expand Down
7 changes: 6 additions & 1 deletion content/renderer/p2p/p2p_transport_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include "jingle/glue/thread_wrapper.h"
#include "jingle/glue/utils.h"
#include "net/base/net_errors.h"
#include "third_party/libjingle/source/talk/base/helpers.h"
#include "third_party/libjingle/source/talk/p2p/base/constants.h"
#include "third_party/libjingle/source/talk/p2p/base/p2ptransportchannel.h"
#include "third_party/libjingle/source/talk/p2p/client/basicportallocator.h"

Expand Down Expand Up @@ -75,7 +77,10 @@ bool P2PTransportImpl::Init(WebKit::WebFrame* web_frame,

DCHECK(!channel_.get());
channel_.reset(new cricket::P2PTransportChannel(
name, 0, NULL, allocator_.get()));
0, NULL, allocator_.get()));
channel_->SetIceUfrag(
talk_base::CreateRandomString(cricket::ICE_UFRAG_LENGTH));
channel_->SetIcePwd(talk_base::CreateRandomString(cricket::ICE_PWD_LENGTH));
channel_->SignalRequestSignaling.connect(
this, &P2PTransportImpl::OnRequestSignaling);
channel_->SignalCandidateReady.connect(
Expand Down
21 changes: 13 additions & 8 deletions content/renderer/p2p/port_allocator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,22 @@ P2PPortAllocator::P2PPortAllocator(
P2PPortAllocator::~P2PPortAllocator() {
}

cricket::PortAllocatorSession* P2PPortAllocator::CreateSession(
const std::string& channel_name,
int component) {
return new P2PPortAllocatorSession(this, channel_name, component);
cricket::PortAllocatorSession* P2PPortAllocator::CreateSessionInternal(
int component,
const std::string& ice_username_fragment,
const std::string& ice_password) {
return new P2PPortAllocatorSession(
this, component, ice_username_fragment, ice_password);
}

P2PPortAllocatorSession::P2PPortAllocatorSession(
P2PPortAllocator* allocator,
const std::string& channel_name,
int component)
: cricket::BasicPortAllocatorSession(allocator, channel_name, component),
int component,
const std::string& ice_username_fragment,
const std::string& ice_password)
: cricket::BasicPortAllocatorSession(
allocator, component,
ice_username_fragment, ice_password),
allocator_(allocator),
relay_session_attempts_(0),
relay_udp_port_(0),
Expand Down Expand Up @@ -221,7 +226,7 @@ void P2PPortAllocatorSession::AllocateRelaySession() {
WebString::fromUTF8("X-Google-Relay-Auth"),
WebString::fromUTF8(allocator_->config_.relay_password));
request.addHTTPHeaderField(WebString::fromUTF8("X-Stream-Type"),
WebString::fromUTF8(channel_name()));
WebString::fromUTF8("chromoting"));

relay_session_request_->loadAsynchronously(request, this);
}
Expand Down
12 changes: 7 additions & 5 deletions content/renderer/p2p/port_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ class P2PPortAllocator : public cricket::BasicPortAllocator {
const webkit_glue::P2PTransport::Config& config);
virtual ~P2PPortAllocator();

virtual cricket::PortAllocatorSession* CreateSession(
const std::string& channel_name,
int component) OVERRIDE;
virtual cricket::PortAllocatorSession* CreateSessionInternal(
int component,
const std::string& ice_username_fragment,
const std::string& ice_password) OVERRIDE;

private:
friend class P2PPortAllocatorSession;
Expand All @@ -53,8 +54,9 @@ class P2PPortAllocatorSession : public cricket::BasicPortAllocatorSession,
public:
P2PPortAllocatorSession(
P2PPortAllocator* allocator,
const std::string& channel_name,
int candidate);
int component,
const std::string& ice_username_fragment,
const std::string& ice_password);
virtual ~P2PPortAllocatorSession();

// WebKit::WebURLLoaderClient overrides.
Expand Down
2 changes: 1 addition & 1 deletion jingle/glue/channel_socket_adapter_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const int kTestError = -32123;
class MockTransportChannel : public cricket::TransportChannel {
public:
MockTransportChannel()
: cricket::TransportChannel("", 0) {
: cricket::TransportChannel(0) {
set_writable(true);
set_readable(true);
}
Expand Down
2 changes: 1 addition & 1 deletion jingle/glue/utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ bool SocketAddressToIPEndPoint(const talk_base::SocketAddress& address_lj,
std::string SerializeP2PCandidate(const cricket::Candidate& candidate) {
// TODO(sergeyu): Use SDP to format candidates?
DictionaryValue value;
value.SetString("ip", candidate.address().IPAsString());
value.SetString("ip", candidate.address().ipaddr().ToString());
value.SetInteger("port", candidate.address().port());
value.SetString("type", candidate.type());
value.SetString("protocol", candidate.protocol());
Expand Down
11 changes: 8 additions & 3 deletions jingle/notifier/base/gaia_token_pre_xmpp_auth.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ void GaiaTokenPreXmppAuth::StartPreXmppAuth(
const buzz::Jid& jid,
const talk_base::SocketAddress& server,
const talk_base::CryptString& pass,
const std::string& auth_cookie) {
const std::string& auth_mechanism,
const std::string& auth_token) {
SignalAuthDone();
}

Expand All @@ -93,8 +94,12 @@ buzz::CaptchaChallenge GaiaTokenPreXmppAuth::GetCaptchaChallenge() const {
return buzz::CaptchaChallenge();
}

std::string GaiaTokenPreXmppAuth::GetAuthCookie() const {
return std::string();
std::string GaiaTokenPreXmppAuth::GetAuthToken() const {
return token_;
}

std::string GaiaTokenPreXmppAuth::GetAuthMechanism() const {
return auth_mechanism_;
}

std::string GaiaTokenPreXmppAuth::ChooseBestSaslMechanism(
Expand Down
7 changes: 5 additions & 2 deletions jingle/notifier/base/gaia_token_pre_xmpp_auth.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class GaiaTokenPreXmppAuth : public buzz::PreXmppAuth {
virtual void StartPreXmppAuth(const buzz::Jid& jid,
const talk_base::SocketAddress& server,
const talk_base::CryptString& pass,
const std::string& auth_cookie) OVERRIDE;
const std::string& auth_mechanism,
const std::string& auth_token) OVERRIDE;

virtual bool IsAuthDone() const OVERRIDE;

Expand All @@ -42,7 +43,9 @@ class GaiaTokenPreXmppAuth : public buzz::PreXmppAuth {

virtual buzz::CaptchaChallenge GetCaptchaChallenge() const OVERRIDE;

virtual std::string GetAuthCookie() const OVERRIDE;
virtual std::string GetAuthToken() const OVERRIDE;

virtual std::string GetAuthMechanism() const OVERRIDE;

// buzz::SaslHandler implementation.

Expand Down
3 changes: 2 additions & 1 deletion jingle/notifier/base/notifier_options_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "base/logging.h"
#include "jingle/notifier/base/const_communicator.h"
#include "jingle/notifier/base/notifier_options.h"
#include "talk/xmpp/constants.h"
#include "talk/xmpp/jid.h"

namespace notifier {
Expand All @@ -23,7 +24,7 @@ buzz::XmppClientSettings MakeXmppClientSettings(
xmpp_client_settings.set_resource("chrome-sync");
xmpp_client_settings.set_host(jid.domain());
xmpp_client_settings.set_use_tls(buzz::TLS_ENABLED);
xmpp_client_settings.set_auth_cookie(
xmpp_client_settings.set_auth_token(buzz::AUTH_MECHANISM_GOOGLE_TOKEN,
notifier_options.invalidate_xmpp_login ?
token + "bogus" : token);
xmpp_client_settings.set_token_service("chromiumsync");
Expand Down
13 changes: 8 additions & 5 deletions jingle/notifier/base/xmpp_connection_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,19 @@ class MockPreXmppAuth : public buzz::PreXmppAuth {
std::string(const std::vector<std::string>&, bool));
MOCK_METHOD1(CreateSaslMechanism,
buzz::SaslMechanism*(const std::string&));
MOCK_METHOD4(StartPreXmppAuth,
MOCK_METHOD5(StartPreXmppAuth,
void(const buzz::Jid&,
const talk_base::SocketAddress&,
const talk_base::CryptString&,
const std::string&,
const std::string&));
MOCK_CONST_METHOD0(IsAuthDone, bool());
MOCK_CONST_METHOD0(IsAuthorized, bool());
MOCK_CONST_METHOD0(HadError, bool());
MOCK_CONST_METHOD0(GetError, int());
MOCK_CONST_METHOD0(GetCaptchaChallenge, buzz::CaptchaChallenge());
MOCK_CONST_METHOD0(GetAuthCookie, std::string());
MOCK_CONST_METHOD0(GetAuthToken, std::string());
MOCK_CONST_METHOD0(GetAuthMechanism, std::string());
};

class MockXmppConnectionDelegate : public XmppConnection::Delegate {
Expand Down Expand Up @@ -113,7 +115,7 @@ TEST_F(XmppConnectionTest, ImmediateFailure) {
}

TEST_F(XmppConnectionTest, PreAuthFailure) {
EXPECT_CALL(*mock_pre_xmpp_auth_, StartPreXmppAuth(_, _, _, _));
EXPECT_CALL(*mock_pre_xmpp_auth_, StartPreXmppAuth(_, _, _, _,_));
EXPECT_CALL(*mock_pre_xmpp_auth_, IsAuthDone()).WillOnce(Return(true));
EXPECT_CALL(*mock_pre_xmpp_auth_, IsAuthorized()).WillOnce(Return(false));
EXPECT_CALL(*mock_pre_xmpp_auth_, HadError()).WillOnce(Return(true));
Expand All @@ -132,10 +134,11 @@ TEST_F(XmppConnectionTest, PreAuthFailure) {
}

TEST_F(XmppConnectionTest, FailureAfterPreAuth) {
EXPECT_CALL(*mock_pre_xmpp_auth_, StartPreXmppAuth(_, _, _, _));
EXPECT_CALL(*mock_pre_xmpp_auth_, StartPreXmppAuth(_, _, _, _,_));
EXPECT_CALL(*mock_pre_xmpp_auth_, IsAuthDone()).WillOnce(Return(true));
EXPECT_CALL(*mock_pre_xmpp_auth_, IsAuthorized()).WillOnce(Return(true));
EXPECT_CALL(*mock_pre_xmpp_auth_, GetAuthCookie()).WillOnce(Return(""));
EXPECT_CALL(*mock_pre_xmpp_auth_, GetAuthMechanism()).WillOnce(Return(""));
EXPECT_CALL(*mock_pre_xmpp_auth_, GetAuthToken()).WillOnce(Return(""));

EXPECT_CALL(mock_xmpp_connection_delegate_,
OnError(buzz::XmppEngine::ERROR_NONE, 0, NULL));
Expand Down
2 changes: 1 addition & 1 deletion jingle/notifier/communicator/single_login_attempt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void SingleLoginAttempt::TryConnect(
buzz::STR_EMPTY);
buzz::PreXmppAuth* pre_xmpp_auth =
new GaiaTokenPreXmppAuth(
jid.Str(), client_settings.auth_cookie(),
jid.Str(), client_settings.auth_token(),
client_settings.token_service(),
login_settings_.auth_mechanism());
xmpp_connection_.reset(
Expand Down
27 changes: 15 additions & 12 deletions remoting/client/plugin/pepper_port_allocator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ class PepperPortAllocatorSession
public:
PepperPortAllocatorSession(
cricket::HttpPortAllocatorBase* allocator,
const std::string& channel_name,
int component,
const std::string& ice_username_fragment,
const std::string& ice_password,
const std::vector<talk_base::SocketAddress>& stun_hosts,
const std::vector<std::string>& relay_hosts,
const std::string& relay_token,
Expand Down Expand Up @@ -73,15 +74,16 @@ class PepperPortAllocatorSession

PepperPortAllocatorSession::PepperPortAllocatorSession(
cricket::HttpPortAllocatorBase* allocator,
const std::string& channel_name,
int component,
const std::string& ice_username_fragment,
const std::string& ice_password,
const std::vector<talk_base::SocketAddress>& stun_hosts,
const std::vector<std::string>& relay_hosts,
const std::string& relay_token,
const pp::InstanceHandle& instance)
: cricket::HttpPortAllocatorSessionBase(
allocator, channel_name, component, stun_hosts,
relay_hosts, relay_token, ""),
: HttpPortAllocatorSessionBase(
allocator, component, ice_username_fragment, ice_password,
stun_hosts, relay_hosts, relay_token, ""),
instance_(instance),
stun_address_resolver_(instance_),
stun_port_(0),
Expand Down Expand Up @@ -204,7 +206,7 @@ void PepperPortAllocatorSession::SendSessionRequest(
std::stringstream headers;
headers << "X-Talk-Google-Relay-Auth: " << relay_token() << "\n\r";
headers << "X-Google-Relay-Auth: " << relay_token() << "\n\r";
headers << "X-StreamType: " << channel_name() << "\n\r";
headers << "X-Stream-Type: " << "chromoting" << "\n\r";
request_info.SetHeaders(headers.str());

int result = relay_url_loader_->Open(request_info, pp::CompletionCallback(
Expand Down Expand Up @@ -328,12 +330,13 @@ PepperPortAllocator::PepperPortAllocator(
PepperPortAllocator::~PepperPortAllocator() {
}

cricket::PortAllocatorSession* PepperPortAllocator::CreateSession(
const std::string& channel_name,
int component) {
return new PepperPortAllocatorSession(
this, channel_name, component, stun_hosts(),
relay_hosts(), relay_token(), instance_);
cricket::PortAllocatorSession* PepperPortAllocator::CreateSessionInternal(
int component,
const std::string& ice_username_fragment,
const std::string& ice_password) {
return new PepperPortAllocatorSession(
this, component, ice_username_fragment, ice_password,
stun_hosts(), relay_hosts(), relay_token(), instance_);
}

} // namespace remoting
7 changes: 4 additions & 3 deletions remoting/client/plugin/pepper_port_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ class PepperPortAllocator : public cricket::HttpPortAllocatorBase {
virtual ~PepperPortAllocator();

// cricket::HttpPortAllocatorBase overrides.
virtual cricket::PortAllocatorSession* CreateSession(
const std::string& channel_name,
int component) OVERRIDE;
virtual cricket::PortAllocatorSession* CreateSessionInternal(
int component,
const std::string& ice_username_fragment,
const std::string& ice_password) OVERRIDE;

private:
PepperPortAllocator(
Expand Down
Loading

0 comments on commit 71a0c6b

Please sign in to comment.