OLD | NEW |
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 "chrome/browser/google_apis/auth_service.h" | 8 #include "chrome/browser/google_apis/auth_service.h" |
9 #include "chrome/browser/google_apis/base_requests.h" | 9 #include "chrome/browser/google_apis/base_requests.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 RequestSender::~RequestSender() { | 29 RequestSender::~RequestSender() { |
30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
31 } | 31 } |
32 | 32 |
33 void RequestSender::Initialize() { | 33 void RequestSender::Initialize() { |
34 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 34 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
35 auth_service_->Initialize(profile_); | 35 auth_service_->Initialize(profile_); |
36 } | 36 } |
37 | 37 |
38 void RequestSender::CancelAll() { | |
39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
40 request_registry_->CancelAll(); | |
41 } | |
42 | |
43 base::Closure RequestSender::StartRequestWithRetry( | 38 base::Closure RequestSender::StartRequestWithRetry( |
44 AuthenticatedRequestInterface* request) { | 39 AuthenticatedRequestInterface* request) { |
45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 40 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
46 | 41 |
47 // TODO(kinaba): Stop relying on weak pointers. Move lifetime management | 42 // TODO(kinaba): Stop relying on weak pointers. Move lifetime management |
48 // of the requests to request sender. | 43 // of the requests to request sender. |
49 base::Closure cancel_closure = | 44 base::Closure cancel_closure = |
50 base::Bind(&RequestSender::CancelRequest, | 45 base::Bind(&RequestSender::CancelRequest, |
51 weak_ptr_factory_.GetWeakPtr(), | 46 weak_ptr_factory_.GetWeakPtr(), |
52 request->GetWeakPtr()); | 47 request->GetWeakPtr()); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 const base::WeakPtr<AuthenticatedRequestInterface>& request) { | 93 const base::WeakPtr<AuthenticatedRequestInterface>& request) { |
99 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 94 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
100 | 95 |
101 // Do nothing if the request is already finished. | 96 // Do nothing if the request is already finished. |
102 if (!request.get()) | 97 if (!request.get()) |
103 return; | 98 return; |
104 request_registry_->CancelRequest(request->AsRequestRegistryRequest()); | 99 request_registry_->CancelRequest(request->AsRequestRegistryRequest()); |
105 } | 100 } |
106 | 101 |
107 } // namespace google_apis | 102 } // namespace google_apis |
OLD | NEW |