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

Side by Side Diff: sync/internal_api/syncapi_server_connection_manager.cc

Issue 15421011: Use OAuth2 token for sync (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "sync/internal_api/syncapi_server_connection_manager.h" 5 #include "sync/internal_api/syncapi_server_connection_manager.h"
6 6
7 #include "net/base/net_errors.h" 7 #include "net/base/net_errors.h"
8 #include "net/http/http_status_code.h" 8 #include "net/http/http_status_code.h"
9 #include "sync/internal_api/public/http_post_provider_factory.h" 9 #include "sync/internal_api/public/http_post_provider_factory.h"
10 #include "sync/internal_api/public/http_post_provider_interface.h" 10 #include "sync/internal_api/public/http_post_provider_interface.h"
(...skipping 20 matching lines...) Expand all
31 std::string sync_server; 31 std::string sync_server;
32 int sync_server_port = 0; 32 int sync_server_port = 0;
33 bool use_ssl = false; 33 bool use_ssl = false;
34 GetServerParams(&sync_server, &sync_server_port, &use_ssl); 34 GetServerParams(&sync_server, &sync_server_port, &use_ssl);
35 std::string connection_url = MakeConnectionURL(sync_server, path, use_ssl); 35 std::string connection_url = MakeConnectionURL(sync_server, path, use_ssl);
36 36
37 HttpPostProviderInterface* http = post_provider_; 37 HttpPostProviderInterface* http = post_provider_;
38 http->SetURL(connection_url.c_str(), sync_server_port); 38 http->SetURL(connection_url.c_str(), sync_server_port);
39 39
40 if (!auth_token.empty()) { 40 if (!auth_token.empty()) {
41 const std::string& headers = 41 const std::string& headers = "Authorization: Bearer " + auth_token;
42 "Authorization: GoogleLogin auth=" + auth_token; 42 http->SetExtraRequestHeaders(headers.c_str());
43 http->SetExtraRequestHeaders(headers.c_str());
44 } 43 }
45 44
46 // Must be octet-stream, or the payload may be parsed for a cookie. 45 // Must be octet-stream, or the payload may be parsed for a cookie.
47 http->SetPostPayload("application/octet-stream", payload.length(), 46 http->SetPostPayload("application/octet-stream", payload.length(),
48 payload.data()); 47 payload.data());
49 48
50 // Issue the POST, blocking until it finishes. 49 // Issue the POST, blocking until it finishes.
51 int error_code = 0; 50 int error_code = 0;
52 int response_code = 0; 51 int response_code = 0;
53 if (!http->MakeSynchronousPost(&error_code, &response_code)) { 52 if (!http->MakeSynchronousPost(&error_code, &response_code)) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 } 93 }
95 94
96 SyncAPIServerConnectionManager::~SyncAPIServerConnectionManager() {} 95 SyncAPIServerConnectionManager::~SyncAPIServerConnectionManager() {}
97 96
98 ServerConnectionManager::Connection* 97 ServerConnectionManager::Connection*
99 SyncAPIServerConnectionManager::MakeConnection() { 98 SyncAPIServerConnectionManager::MakeConnection() {
100 return new SyncAPIBridgedConnection(this, post_provider_factory_.get()); 99 return new SyncAPIBridgedConnection(this, post_provider_factory_.get());
101 } 100 }
102 101
103 } // namespace syncer 102 } // namespace syncer
OLDNEW
« sync/internal_api/sync_manager_impl.cc ('K') | « sync/internal_api/sync_manager_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698