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

Side by Side Diff: chrome/browser/google_apis/request_sender.cc

Issue 19511002: Change google_api::RequestSender to take an AuthService instead of a Profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/google_apis/request_sender.h ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/google_apis/request_sender.h" 5 #include "chrome/browser/google_apis/request_sender.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "chrome/browser/google_apis/auth_service.h" 9 #include "chrome/browser/google_apis/auth_service.h"
10 #include "chrome/browser/google_apis/base_requests.h" 10 #include "chrome/browser/google_apis/base_requests.h"
11 11
12 namespace google_apis { 12 namespace google_apis {
13 13
14 RequestSender::RequestSender( 14 RequestSender::RequestSender(
15 Profile* profile, 15 AuthServiceInterface* auth_service,
16 net::URLRequestContextGetter* url_request_context_getter, 16 net::URLRequestContextGetter* url_request_context_getter,
17 base::TaskRunner* blocking_task_runner, 17 base::TaskRunner* blocking_task_runner,
18 const std::vector<std::string>& scopes,
19 const std::string& custom_user_agent) 18 const std::string& custom_user_agent)
20 : profile_(profile), 19 : auth_service_(auth_service),
21 url_request_context_getter_(url_request_context_getter), 20 url_request_context_getter_(url_request_context_getter),
22 blocking_task_runner_(blocking_task_runner), 21 blocking_task_runner_(blocking_task_runner),
23 auth_service_(new AuthService(url_request_context_getter, scopes)),
24 custom_user_agent_(custom_user_agent), 22 custom_user_agent_(custom_user_agent),
25 weak_ptr_factory_(this) { 23 weak_ptr_factory_(this) {
26 DCHECK(thread_checker_.CalledOnValidThread()); 24 DCHECK(thread_checker_.CalledOnValidThread());
27 } 25 }
28 26
29 RequestSender::~RequestSender() { 27 RequestSender::~RequestSender() {
30 DCHECK(thread_checker_.CalledOnValidThread()); 28 DCHECK(thread_checker_.CalledOnValidThread());
31 STLDeleteContainerPointers(in_flight_requests_.begin(), 29 STLDeleteContainerPointers(in_flight_requests_.begin(),
32 in_flight_requests_.end()); 30 in_flight_requests_.end());
33 } 31 }
34 32
35 void RequestSender::Initialize() {
36 DCHECK(thread_checker_.CalledOnValidThread());
37 auth_service_->Initialize(profile_);
38 }
39
40 base::Closure RequestSender::StartRequestWithRetry( 33 base::Closure RequestSender::StartRequestWithRetry(
41 AuthenticatedRequestInterface* request) { 34 AuthenticatedRequestInterface* request) {
42 DCHECK(thread_checker_.CalledOnValidThread()); 35 DCHECK(thread_checker_.CalledOnValidThread());
43 36
44 in_flight_requests_.insert(request); 37 in_flight_requests_.insert(request);
45 38
46 // TODO(kinaba): Stop relying on weak pointers. Move lifetime management 39 // TODO(kinaba): Stop relying on weak pointers. Move lifetime management
47 // of the requests to request sender. 40 // of the requests to request sender.
48 base::Closure cancel_closure = 41 base::Closure cancel_closure =
49 base::Bind(&RequestSender::CancelRequest, 42 base::Bind(&RequestSender::CancelRequest,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 return; 95 return;
103 request->Cancel(); 96 request->Cancel();
104 } 97 }
105 98
106 void RequestSender::RequestFinished(AuthenticatedRequestInterface* request) { 99 void RequestSender::RequestFinished(AuthenticatedRequestInterface* request) {
107 in_flight_requests_.erase(request); 100 in_flight_requests_.erase(request);
108 delete request; 101 delete request;
109 } 102 }
110 103
111 } // namespace google_apis 104 } // namespace google_apis
OLDNEW
« no previous file with comments | « chrome/browser/google_apis/request_sender.h ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698