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

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

Issue 11824019: Move drive_api_service.cc/.h from chrome/browser/chromeos/drive to chrome/google_apis. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix update conflicts Created 7 years, 11 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 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_API_SERVICE_H_ 5 #ifndef CHROME_BROWSER_GOOGLE_APIS_DRIVE_API_SERVICE_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_API_SERVICE_H_ 6 #define CHROME_BROWSER_GOOGLE_APIS_DRIVE_API_SERVICE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/observer_list.h" 11 #include "base/observer_list.h"
12 #include "chrome/browser/google_apis/auth_service.h" 12 #include "chrome/browser/google_apis/auth_service.h"
13 #include "chrome/browser/google_apis/auth_service_observer.h" 13 #include "chrome/browser/google_apis/auth_service_observer.h"
14 #include "chrome/browser/google_apis/drive_api_url_generator.h" 14 #include "chrome/browser/google_apis/drive_api_url_generator.h"
15 #include "chrome/browser/google_apis/drive_service_interface.h" 15 #include "chrome/browser/google_apis/drive_service_interface.h"
16 16
17 class FilePath; 17 class FilePath;
18 class GURL; 18 class GURL;
19 class Profile; 19 class Profile;
20 20
21 namespace google_apis {
22 class OperationRunner;
23 } // namespace google_apis
24
25 namespace net { 21 namespace net {
26 class URLRequestContextGetter; 22 class URLRequestContextGetter;
27 } // namespace net 23 } // namespace net
28 24
29 namespace drive { 25 namespace google_apis {
26 class OperationRunner;
30 27
31 // This class provides documents feed service calls for Drive V2 API. 28 // This class provides documents feed service calls for Drive V2 API.
32 // Details of API call are abstracted in each operation class and this class 29 // Details of API call are abstracted in each operation class and this class
33 // works as a thin wrapper for the API. 30 // works as a thin wrapper for the API.
34 class DriveAPIService : public google_apis::DriveServiceInterface, 31 class DriveAPIService : public DriveServiceInterface,
35 public google_apis::AuthServiceObserver, 32 public AuthServiceObserver,
36 public google_apis::OperationRegistryObserver { 33 public OperationRegistryObserver {
37 public: 34 public:
38 // Instance is usually created by DriveSystemServiceFactory and owned by 35 // Instance is usually created by DriveSystemServiceFactory and owned by
39 // DriveFileSystem. 36 // DriveFileSystem.
40 // 37 //
41 // |url_request_context_getter| is used to initialize URLFetcher. 38 // |url_request_context_getter| is used to initialize URLFetcher.
42 // |base_url| is used to generate URLs for communication with the drive API. 39 // |base_url| is used to generate URLs for communication with the drive API.
43 // |custom_user_agent| will be used for the User-Agent header in HTTP 40 // |custom_user_agent| will be used for the User-Agent header in HTTP
44 // requests issues through the service if the value is not empty. 41 // requests issues through the service if the value is not empty.
45 DriveAPIService( 42 DriveAPIService(
46 net::URLRequestContextGetter* url_request_context_getter, 43 net::URLRequestContextGetter* url_request_context_getter,
47 const GURL& base_url, 44 const GURL& base_url,
48 const std::string& custom_user_agent); 45 const std::string& custom_user_agent);
49 virtual ~DriveAPIService(); 46 virtual ~DriveAPIService();
50 47
51 // DriveServiceInterface Overrides 48 // DriveServiceInterface Overrides
52 virtual void Initialize(Profile* profile) OVERRIDE; 49 virtual void Initialize(Profile* profile) OVERRIDE;
53 virtual void AddObserver( 50 virtual void AddObserver(DriveServiceObserver* observer) OVERRIDE;
54 google_apis::DriveServiceObserver* observer) OVERRIDE; 51 virtual void RemoveObserver(DriveServiceObserver* observer) OVERRIDE;
55 virtual void RemoveObserver(
56 google_apis::DriveServiceObserver* observer) OVERRIDE;
57 virtual bool CanStartOperation() const OVERRIDE; 52 virtual bool CanStartOperation() const OVERRIDE;
58 virtual void CancelAll() OVERRIDE; 53 virtual void CancelAll() OVERRIDE;
59 virtual bool CancelForFilePath(const FilePath& file_path) OVERRIDE; 54 virtual bool CancelForFilePath(const FilePath& file_path) OVERRIDE;
60 virtual google_apis::OperationProgressStatusList GetProgressStatusList() 55 virtual OperationProgressStatusList GetProgressStatusList() const OVERRIDE;
61 const OVERRIDE;
62 virtual bool HasAccessToken() const OVERRIDE; 56 virtual bool HasAccessToken() const OVERRIDE;
63 virtual bool HasRefreshToken() const OVERRIDE; 57 virtual bool HasRefreshToken() const OVERRIDE;
64 virtual void GetResourceList( 58 virtual void GetResourceList(
65 const GURL& feed_url, 59 const GURL& feed_url,
66 int64 start_changestamp, 60 int64 start_changestamp,
67 const std::string& search_query, 61 const std::string& search_query,
68 bool shared_with_me, 62 bool shared_with_me,
69 const std::string& directory_resource_id, 63 const std::string& directory_resource_id,
70 const google_apis::GetResourceListCallback& callback) OVERRIDE; 64 const GetResourceListCallback& callback) OVERRIDE;
71 virtual void GetResourceEntry( 65 virtual void GetResourceEntry(
72 const std::string& resource_id, 66 const std::string& resource_id,
73 const google_apis::GetResourceEntryCallback& callback) OVERRIDE; 67 const GetResourceEntryCallback& callback) OVERRIDE;
74 68
75 virtual void GetAccountMetadata( 69 virtual void GetAccountMetadata(
76 const google_apis::GetAccountMetadataCallback& callback) OVERRIDE; 70 const GetAccountMetadataCallback& callback) OVERRIDE;
77 virtual void GetApplicationInfo( 71 virtual void GetApplicationInfo(const GetDataCallback& callback) OVERRIDE;
78 const google_apis::GetDataCallback& callback) OVERRIDE;
79 virtual void DeleteResource( 72 virtual void DeleteResource(
80 const GURL& edit_url, 73 const GURL& edit_url,
81 const google_apis::EntryActionCallback& callback) OVERRIDE; 74 const EntryActionCallback& callback) OVERRIDE;
82 virtual void DownloadHostedDocument( 75 virtual void DownloadHostedDocument(
83 const FilePath& virtual_path, 76 const FilePath& virtual_path,
84 const FilePath& local_cache_path, 77 const FilePath& local_cache_path,
85 const GURL& content_url, 78 const GURL& content_url,
86 google_apis::DocumentExportFormat format, 79 DocumentExportFormat format,
87 const google_apis::DownloadActionCallback& callback) OVERRIDE; 80 const DownloadActionCallback& callback) OVERRIDE;
88 virtual void DownloadFile( 81 virtual void DownloadFile(
89 const FilePath& virtual_path, 82 const FilePath& virtual_path,
90 const FilePath& local_cache_path, 83 const FilePath& local_cache_path,
91 const GURL& content_url, 84 const GURL& content_url,
92 const google_apis::DownloadActionCallback& download_action_callback, 85 const DownloadActionCallback& download_action_callback,
93 const google_apis::GetContentCallback& get_content_callback) OVERRIDE; 86 const GetContentCallback& get_content_callback) OVERRIDE;
94 virtual void CopyHostedDocument( 87 virtual void CopyHostedDocument(
95 const std::string& resource_id, 88 const std::string& resource_id,
96 const FilePath::StringType& new_name, 89 const FilePath::StringType& new_name,
97 const google_apis::GetResourceEntryCallback& callback) OVERRIDE; 90 const GetResourceEntryCallback& callback) OVERRIDE;
98 virtual void RenameResource( 91 virtual void RenameResource(
99 const GURL& edit_url, 92 const GURL& edit_url,
100 const FilePath::StringType& new_name, 93 const FilePath::StringType& new_name,
101 const google_apis::EntryActionCallback& callback) OVERRIDE; 94 const EntryActionCallback& callback) OVERRIDE;
102 virtual void AddResourceToDirectory( 95 virtual void AddResourceToDirectory(
103 const GURL& parent_content_url, 96 const GURL& parent_content_url,
104 const GURL& edit_url, 97 const GURL& edit_url,
105 const google_apis::EntryActionCallback& callback) OVERRIDE; 98 const EntryActionCallback& callback) OVERRIDE;
106 virtual void RemoveResourceFromDirectory( 99 virtual void RemoveResourceFromDirectory(
107 const GURL& parent_content_url, 100 const GURL& parent_content_url,
108 const std::string& resource_id, 101 const std::string& resource_id,
109 const google_apis::EntryActionCallback& callback) OVERRIDE; 102 const EntryActionCallback& callback) OVERRIDE;
110 virtual void AddNewDirectory( 103 virtual void AddNewDirectory(
111 const GURL& parent_content_url, 104 const GURL& parent_content_url,
112 const FilePath::StringType& directory_name, 105 const FilePath::StringType& directory_name,
113 const google_apis::GetResourceEntryCallback& callback) OVERRIDE; 106 const GetResourceEntryCallback& callback) OVERRIDE;
114 virtual void InitiateUpload( 107 virtual void InitiateUpload(
115 const google_apis::InitiateUploadParams& params, 108 const InitiateUploadParams& params,
116 const google_apis::InitiateUploadCallback& callback) OVERRIDE; 109 const InitiateUploadCallback& callback) OVERRIDE;
117 virtual void ResumeUpload( 110 virtual void ResumeUpload(
118 const google_apis::ResumeUploadParams& params, 111 const ResumeUploadParams& params,
119 const google_apis::ResumeUploadCallback& callback) OVERRIDE; 112 const ResumeUploadCallback& callback) OVERRIDE;
120 virtual void AuthorizeApp( 113 virtual void AuthorizeApp(
121 const GURL& edit_url, 114 const GURL& edit_url,
122 const std::string& app_id, 115 const std::string& app_id,
123 const google_apis::AuthorizeAppCallback& callback) OVERRIDE; 116 const AuthorizeAppCallback& callback) OVERRIDE;
124 117
125 private: 118 private:
126 google_apis::OperationRegistry* operation_registry() const; 119 OperationRegistry* operation_registry() const;
127 120
128 // Fetches a changelist from |url| with |start_changestamp|, using Drive V2 121 // Fetches a changelist from |url| with |start_changestamp|, using Drive V2
129 // API. If this URL is empty the call will use the default URL. Specify |url| 122 // API. If this URL is empty the call will use the default URL. Specify |url|
130 // when pagenated request should be issued. 123 // when pagenated request should be issued.
131 // |start_changestamp| specifies the starting point of change list or 0 if 124 // |start_changestamp| specifies the starting point of change list or 0 if
132 // all changes are necessary. 125 // all changes are necessary.
133 // Upon completion, invokes |callback| with results on calling thread. 126 // Upon completion, invokes |callback| with results on calling thread.
134 void GetChangelist(const GURL& url, 127 void GetChangelist(const GURL& url,
135 int64 start_changestamp, 128 int64 start_changestamp,
136 const google_apis::GetResourceListCallback& callback); 129 const GetResourceListCallback& callback);
137 130
138 // Fetches a filelist from |url| with |search_query|, using Drive V2 API. If 131 // Fetches a filelist from |url| with |search_query|, using Drive V2 API. If
139 // this URL is empty the call will use the default URL. Specify |url| when 132 // this URL is empty the call will use the default URL. Specify |url| when
140 // pagenated request should be issued. 133 // pagenated request should be issued.
141 // |search_query| specifies query string, whose syntax is described at 134 // |search_query| specifies query string, whose syntax is described at
142 // https://developers.google.com/drive/search-parameters 135 // https://developers.google.com/drive/search-parameters
143 void GetFilelist(const GURL& url, 136 void GetFilelist(const GURL& url,
144 const std::string& search_query, 137 const std::string& search_query,
145 const google_apis::GetResourceListCallback& callback); 138 const GetResourceListCallback& callback);
146 139
147 // AuthService::Observer override. 140 // AuthService::Observer override.
148 virtual void OnOAuth2RefreshTokenChanged() OVERRIDE; 141 virtual void OnOAuth2RefreshTokenChanged() OVERRIDE;
149 142
150 // DriveServiceObserver Overrides 143 // DriveServiceObserver Overrides
151 virtual void OnProgressUpdate( 144 virtual void OnProgressUpdate(
152 const google_apis::OperationProgressStatusList& list) OVERRIDE; 145 const OperationProgressStatusList& list) OVERRIDE;
153 virtual void OnAuthenticationFailed( 146 virtual void OnAuthenticationFailed(GDataErrorCode error) OVERRIDE;
154 google_apis::GDataErrorCode error) OVERRIDE;
155 147
156 net::URLRequestContextGetter* url_request_context_getter_; 148 net::URLRequestContextGetter* url_request_context_getter_;
157 Profile* profile_; 149 Profile* profile_;
158 scoped_ptr<google_apis::OperationRunner> runner_; 150 scoped_ptr<OperationRunner> runner_;
159 ObserverList<google_apis::DriveServiceObserver> observers_; 151 ObserverList<DriveServiceObserver> observers_;
160 google_apis::DriveApiUrlGenerator url_generator_; 152 DriveApiUrlGenerator url_generator_;
161 const std::string custom_user_agent_; 153 const std::string custom_user_agent_;
162 154
163 DISALLOW_COPY_AND_ASSIGN(DriveAPIService); 155 DISALLOW_COPY_AND_ASSIGN(DriveAPIService);
164 }; 156 };
165 157
166 } // namespace drive 158 } // namespace google_apis
167 159
168 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_API_SERVICE_H_ 160 #endif // CHROME_BROWSER_GOOGLE_APIS_DRIVE_API_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/drive_system_service.cc ('k') | chrome/browser/google_apis/drive_api_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698