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

Side by Side Diff: chrome/browser/chromeos/gdata/operations_base.h

Issue 10879061: Rename GDataOperationInterface to AuthenticatedOperationInterface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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/chromeos/gdata/operation_runner.cc ('k') | no next file » | 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 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_OPERATIONS_BASE_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_OPERATIONS_BASE_H_
6 #define CHROME_BROWSER_CHROMEOS_GDATA_OPERATIONS_BASE_H_ 6 #define CHROME_BROWSER_CHROMEOS_GDATA_OPERATIONS_BASE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 virtual void DoCancel() OVERRIDE; 46 virtual void DoCancel() OVERRIDE;
47 47
48 private: 48 private:
49 std::string refresh_token_; 49 std::string refresh_token_;
50 AuthStatusCallback callback_; 50 AuthStatusCallback callback_;
51 scoped_ptr<OAuth2AccessTokenFetcher> oauth2_access_token_fetcher_; 51 scoped_ptr<OAuth2AccessTokenFetcher> oauth2_access_token_fetcher_;
52 52
53 DISALLOW_COPY_AND_ASSIGN(AuthOperation); 53 DISALLOW_COPY_AND_ASSIGN(AuthOperation);
54 }; 54 };
55 55
56 //=========================== GDataOperationInterface ========================== 56 //======================= AuthenticatedOperationInterface ======================
57 57
58 // An interface for implementing an operation used by DriveServiceInterface. 58 // An interface for implementing an operation used by DriveServiceInterface.
59 class GDataOperationInterface { 59 class AuthenticatedOperationInterface {
60 public: 60 public:
61 // Callback to DriveServiceInterface upon for re-authentication. 61 // Callback to DriveServiceInterface upon for re-authentication.
62 typedef base::Callback<void(GDataOperationInterface* operation)> 62 typedef base::Callback<void(AuthenticatedOperationInterface* operation)>
63 ReAuthenticateCallback; 63 ReAuthenticateCallback;
64 64
65 virtual ~GDataOperationInterface() {} 65 virtual ~AuthenticatedOperationInterface() {}
66 66
67 // Starts the actual operation after obtaining an authentication token 67 // Starts the actual operation after obtaining an authentication token
68 // |auth_token|. 68 // |auth_token|.
69 virtual void Start(const std::string& auth_token) = 0; 69 virtual void Start(const std::string& auth_token) = 0;
70 70
71 // Invoked when the authentication failed with an error code |code|. 71 // Invoked when the authentication failed with an error code |code|.
72 virtual void OnAuthFailed(GDataErrorCode code) = 0; 72 virtual void OnAuthFailed(GDataErrorCode code) = 0;
73 73
74 // Sets the callback to DriveServiceInterface when the operation restarts due 74 // Sets the callback to DriveServiceInterface when the operation restarts due
75 // to an authentication failure. 75 // to an authentication failure.
76 virtual void SetReAuthenticateCallback( 76 virtual void SetReAuthenticateCallback(
77 const ReAuthenticateCallback& callback) = 0; 77 const ReAuthenticateCallback& callback) = 0;
78 }; 78 };
79 79
80 //============================ UrlFetchOperationBase =========================== 80 //============================ UrlFetchOperationBase ===========================
81 81
82 // Callback type for getting the content from URLFetcher::GetResponseAsString(). 82 // Callback type for getting the content from URLFetcher::GetResponseAsString().
83 typedef base::Callback<void( 83 typedef base::Callback<void(
84 GDataErrorCode error, 84 GDataErrorCode error,
85 scoped_ptr<std::string> content)> GetContentCallback; 85 scoped_ptr<std::string> content)> GetContentCallback;
86 86
87 // Base class for operations that are fetching URLs. 87 // Base class for operations that are fetching URLs.
88 class UrlFetchOperationBase : public GDataOperationInterface, 88 class UrlFetchOperationBase : public AuthenticatedOperationInterface,
89 public OperationRegistry::Operation, 89 public OperationRegistry::Operation,
90 public net::URLFetcherDelegate { 90 public net::URLFetcherDelegate {
91 public: 91 public:
92 // Overridden from GDataOperationInterface. 92 // Overridden from AuthenticatedOperationInterface.
93 virtual void Start(const std::string& auth_token) OVERRIDE; 93 virtual void Start(const std::string& auth_token) OVERRIDE;
94 94
95 // Overridden from GDataOperationInterface. 95 // Overridden from AuthenticatedOperationInterface.
96 virtual void SetReAuthenticateCallback( 96 virtual void SetReAuthenticateCallback(
97 const ReAuthenticateCallback& callback) OVERRIDE; 97 const ReAuthenticateCallback& callback) OVERRIDE;
98 98
99 protected: 99 protected:
100 explicit UrlFetchOperationBase(OperationRegistry* registry); 100 explicit UrlFetchOperationBase(OperationRegistry* registry);
101 UrlFetchOperationBase(OperationRegistry* registry, 101 UrlFetchOperationBase(OperationRegistry* registry,
102 OperationRegistry::OperationType type, 102 OperationRegistry::OperationType type,
103 const FilePath& path); 103 const FilePath& path);
104 virtual ~UrlFetchOperationBase(); 104 virtual ~UrlFetchOperationBase();
105 105
(...skipping 24 matching lines...) Expand all
130 // Invoked by this base class upon an authentication error or cancel by 130 // Invoked by this base class upon an authentication error or cancel by
131 // an user operation. Must be implemented by a derived class. 131 // an user operation. Must be implemented by a derived class.
132 virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) = 0; 132 virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) = 0;
133 133
134 // Implement OperationRegistry::Operation 134 // Implement OperationRegistry::Operation
135 virtual void DoCancel() OVERRIDE; 135 virtual void DoCancel() OVERRIDE;
136 136
137 // Overridden from URLFetcherDelegate. 137 // Overridden from URLFetcherDelegate.
138 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; 138 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
139 139
140 // Overridden from GDataOperationInterface. 140 // Overridden from AuthenticatedOperationInterface.
141 virtual void OnAuthFailed(GDataErrorCode code) OVERRIDE; 141 virtual void OnAuthFailed(GDataErrorCode code) OVERRIDE;
142 142
143 // Invoked when ProcessURLFetchResults() is completed. 143 // Invoked when ProcessURLFetchResults() is completed.
144 void OnProcessURLFetchResultsComplete(bool result); 144 void OnProcessURLFetchResultsComplete(bool result);
145 145
146 // Returns an appropriate GDataErrorCode based on the HTTP response code and 146 // Returns an appropriate GDataErrorCode based on the HTTP response code and
147 // the status of the URLFetcher. 147 // the status of the URLFetcher.
148 GDataErrorCode GetErrorCode(const net::URLFetcher* source) const; 148 GDataErrorCode GetErrorCode(const net::URLFetcher* source) const;
149 149
150 std::string GetResponseHeadersAsString( 150 std::string GetResponseHeadersAsString(
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 223
224 // Note: This should remain the last member so it'll be destroyed and 224 // Note: This should remain the last member so it'll be destroyed and
225 // invalidate its weak pointers before any other members are destroyed. 225 // invalidate its weak pointers before any other members are destroyed.
226 base::WeakPtrFactory<GetDataOperation> weak_ptr_factory_; 226 base::WeakPtrFactory<GetDataOperation> weak_ptr_factory_;
227 DISALLOW_COPY_AND_ASSIGN(GetDataOperation); 227 DISALLOW_COPY_AND_ASSIGN(GetDataOperation);
228 }; 228 };
229 229
230 } // namespace gdata 230 } // namespace gdata
231 231
232 #endif // CHROME_BROWSER_CHROMEOS_GDATA_OPERATIONS_BASE_H_ 232 #endif // CHROME_BROWSER_CHROMEOS_GDATA_OPERATIONS_BASE_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/operation_runner.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698