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

Side by Side Diff: chrome/browser/google_apis/operation_runner.h

Issue 16424004: google_apis: Rename base_operations.h/cc to base_requests.h/cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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
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 #ifndef CHROME_BROWSER_GOOGLE_APIS_OPERATION_RUNNER_H_ 5 #ifndef CHROME_BROWSER_GOOGLE_APIS_OPERATION_RUNNER_H_
6 #define CHROME_BROWSER_GOOGLE_APIS_OPERATION_RUNNER_H_ 6 #define CHROME_BROWSER_GOOGLE_APIS_OPERATION_RUNNER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "chrome/browser/google_apis/gdata_errorcode.h" 14 #include "chrome/browser/google_apis/gdata_errorcode.h"
15 15
16 class Profile; 16 class Profile;
17 17
18 namespace net { 18 namespace net {
19 class URLRequestContextGetter; 19 class URLRequestContextGetter;
20 } 20 }
21 21
22 namespace google_apis { 22 namespace google_apis {
23 23
24 class AuthenticatedOperationInterface; 24 class AuthenticatedRequestInterface;
25 class AuthService; 25 class AuthService;
26 class OperationRegistry; 26 class OperationRegistry;
27 27
28 // Helper class that runs AuthenticatedOperationInterface objects, handling 28 // Helper class that runs AuthenticatedRequestInterface objects, handling
29 // retries and authentication. 29 // retries and authentication.
30 class OperationRunner { 30 class OperationRunner {
31 public: 31 public:
32 // |url_request_context_getter| is used to perform authentication with 32 // |url_request_context_getter| is used to perform authentication with
33 // AuthService. 33 // AuthService.
34 // 34 //
35 // |scopes| specifies OAuth2 scopes. 35 // |scopes| specifies OAuth2 scopes.
36 // 36 //
37 // |custom_user_agent| will be used for the User-Agent header in HTTP 37 // |custom_user_agent| will be used for the User-Agent header in HTTP
38 // requests issued through the operation runner if the value is not empty. 38 // requests issued through the operation runner if the value is not empty.
39 OperationRunner(Profile* profile, 39 OperationRunner(Profile* profile,
40 net::URLRequestContextGetter* url_request_context_getter, 40 net::URLRequestContextGetter* url_request_context_getter,
41 const std::vector<std::string>& scopes, 41 const std::vector<std::string>& scopes,
42 const std::string& custom_user_agent); 42 const std::string& custom_user_agent);
43 virtual ~OperationRunner(); 43 virtual ~OperationRunner();
44 44
45 AuthService* auth_service() { return auth_service_.get(); } 45 AuthService* auth_service() { return auth_service_.get(); }
46 OperationRegistry* operation_registry() { 46 OperationRegistry* operation_registry() {
47 return operation_registry_.get(); 47 return operation_registry_.get();
48 } 48 }
49 49
50 // Prepares the object for use. 50 // Prepares the object for use.
51 virtual void Initialize(); 51 virtual void Initialize();
52 52
53 // Cancels all in-flight operations. 53 // Cancels all in-flight operations.
54 void CancelAll(); 54 void CancelAll();
55 55
56 // Starts an operation implementing the AuthenticatedOperationInterface 56 // Starts an operation implementing the AuthenticatedRequestInterface
57 // interface, and makes the operation retry upon authentication failures by 57 // interface, and makes the operation retry upon authentication failures by
58 // calling back to RetryOperation. 58 // calling back to RetryOperation.
59 void StartOperationWithRetry(AuthenticatedOperationInterface* operation); 59 void StartOperationWithRetry(AuthenticatedRequestInterface* operation);
60 60
61 private: 61 private:
62 // Called when the access token is fetched. 62 // Called when the access token is fetched.
63 void OnAccessTokenFetched( 63 void OnAccessTokenFetched(
64 const base::WeakPtr<AuthenticatedOperationInterface>& operation, 64 const base::WeakPtr<AuthenticatedRequestInterface>& operation,
65 GDataErrorCode error, 65 GDataErrorCode error,
66 const std::string& access_token); 66 const std::string& access_token);
67 67
68 // Clears any authentication token and retries the operation, which forces 68 // Clears any authentication token and retries the operation, which forces
69 // an authentication token refresh. 69 // an authentication token refresh.
70 void RetryOperation(AuthenticatedOperationInterface* operation); 70 void RetryOperation(AuthenticatedRequestInterface* operation);
71 71
72 Profile* profile_; // Not owned. 72 Profile* profile_; // Not owned.
73 73
74 scoped_ptr<AuthService> auth_service_; 74 scoped_ptr<AuthService> auth_service_;
75 scoped_ptr<OperationRegistry> operation_registry_; 75 scoped_ptr<OperationRegistry> operation_registry_;
76 const std::string custom_user_agent_; 76 const std::string custom_user_agent_;
77 77
78 // Note: This should remain the last member so it'll be destroyed and 78 // Note: This should remain the last member so it'll be destroyed and
79 // invalidate its weak pointers before any other members are destroyed. 79 // invalidate its weak pointers before any other members are destroyed.
80 base::WeakPtrFactory<OperationRunner> weak_ptr_factory_; 80 base::WeakPtrFactory<OperationRunner> weak_ptr_factory_;
81 81
82 DISALLOW_COPY_AND_ASSIGN(OperationRunner); 82 DISALLOW_COPY_AND_ASSIGN(OperationRunner);
83 }; 83 };
84 84
85 } // namespace google_apis 85 } // namespace google_apis
86 86
87 #endif // CHROME_BROWSER_GOOGLE_APIS_OPERATION_RUNNER_H_ 87 #endif // CHROME_BROWSER_GOOGLE_APIS_OPERATION_RUNNER_H_
OLDNEW
« no previous file with comments | « chrome/browser/google_apis/gdata_wapi_service.cc ('k') | chrome/browser/google_apis/operation_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698