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 #ifndef GOOGLE_APIS_DRIVE_GDATA_WAPI_REQUESTS_H_ | 5 #ifndef GOOGLE_APIS_DRIVE_GDATA_WAPI_REQUESTS_H_ |
6 #define GOOGLE_APIS_DRIVE_GDATA_WAPI_REQUESTS_H_ | 6 #define GOOGLE_APIS_DRIVE_GDATA_WAPI_REQUESTS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "google_apis/drive/base_requests.h" | 10 #include "google_apis/drive/base_requests.h" |
11 #include "google_apis/drive/gdata_wapi_url_generator.h" | 11 #include "google_apis/drive/gdata_wapi_url_generator.h" |
12 | 12 |
13 namespace google_apis { | 13 namespace google_apis { |
14 | 14 |
15 //========================= GetResourceEntryRequest ========================== | 15 class ResourceEntry; |
| 16 |
| 17 // Callback type for GetResourceEntryRequest. |
| 18 typedef base::Callback<void(GDataErrorCode error, |
| 19 scoped_ptr<ResourceEntry> entry)> |
| 20 GetResourceEntryCallback; |
16 | 21 |
17 // This class performs the request for fetching a single resource entry. | 22 // This class performs the request for fetching a single resource entry. |
18 class GetResourceEntryRequest : public GetDataRequest { | 23 class GetResourceEntryRequest : public UrlFetchRequestBase { |
19 public: | 24 public: |
20 // |callback| must not be null. | 25 // |callback| must not be null. |
21 GetResourceEntryRequest(RequestSender* sender, | 26 GetResourceEntryRequest(RequestSender* sender, |
22 const GDataWapiUrlGenerator& url_generator, | 27 const GDataWapiUrlGenerator& url_generator, |
23 const std::string& resource_id, | 28 const std::string& resource_id, |
24 const GURL& embed_origin, | 29 const GURL& embed_origin, |
25 const GetDataCallback& callback); | 30 const GetResourceEntryCallback& callback); |
26 virtual ~GetResourceEntryRequest(); | 31 virtual ~GetResourceEntryRequest(); |
27 | 32 |
28 protected: | 33 protected: |
29 // UrlFetchRequestBase overrides. | 34 // UrlFetchRequestBase overrides. |
| 35 virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE; |
| 36 virtual void RunCallbackOnPrematureFailure(GDataErrorCode error) OVERRIDE; |
30 virtual GURL GetURL() const OVERRIDE; | 37 virtual GURL GetURL() const OVERRIDE; |
31 | 38 |
32 private: | 39 private: |
| 40 void OnDataParsed(GDataErrorCode error, scoped_ptr<ResourceEntry> entry); |
| 41 |
33 const GDataWapiUrlGenerator url_generator_; | 42 const GDataWapiUrlGenerator url_generator_; |
34 // Resource id of the requested entry. | 43 // Resource id of the requested entry. |
35 const std::string resource_id_; | 44 const std::string resource_id_; |
36 // Embed origin for an url to the sharing dialog. Can be empty. | 45 // Embed origin for an url to the sharing dialog. Can be empty. |
37 const GURL& embed_origin_; | 46 GURL embed_origin_; |
| 47 |
| 48 const GetResourceEntryCallback callback_; |
| 49 |
| 50 // Note: This should remain the last member so it'll be destroyed and |
| 51 // invalidate its weak pointers before any other members are destroyed. |
| 52 base::WeakPtrFactory<GetResourceEntryRequest> weak_ptr_factory_; |
38 | 53 |
39 DISALLOW_COPY_AND_ASSIGN(GetResourceEntryRequest); | 54 DISALLOW_COPY_AND_ASSIGN(GetResourceEntryRequest); |
40 }; | 55 }; |
41 | 56 |
42 } // namespace google_apis | 57 } // namespace google_apis |
43 | 58 |
44 #endif // GOOGLE_APIS_DRIVE_GDATA_WAPI_REQUESTS_H_ | 59 #endif // GOOGLE_APIS_DRIVE_GDATA_WAPI_REQUESTS_H_ |
OLD | NEW |