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

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

Powered by Google App Engine
This is Rietveld 408576698