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.
5 #ifndef GOOGLE_APIS_DRIVE_GDATA_WAPI_REQUESTS_H_
6 #define GOOGLE_APIS_DRIVE_GDATA_WAPI_REQUESTS_H_
10 #include "google_apis/drive/base_requests.h"
11 #include "google_apis/drive/gdata_wapi_url_generator.h"
13 namespace google_apis
{
17 // Callback type for GetResourceEntryRequest.
18 typedef base::Callback
<void(GDataErrorCode error
,
19 scoped_ptr
<ResourceEntry
> entry
)>
20 GetResourceEntryCallback
;
22 // This class performs the request for fetching a single resource entry.
23 class GetResourceEntryRequest
: public UrlFetchRequestBase
{
25 // |callback| must not be null.
26 GetResourceEntryRequest(RequestSender
* sender
,
27 const GDataWapiUrlGenerator
& url_generator
,
28 const std::string
& resource_id
,
29 const GURL
& embed_origin
,
30 const GetResourceEntryCallback
& callback
);
31 virtual ~GetResourceEntryRequest();
34 // UrlFetchRequestBase overrides.
35 virtual void ProcessURLFetchResults(const net::URLFetcher
* source
) OVERRIDE
;
36 virtual void RunCallbackOnPrematureFailure(GDataErrorCode error
) OVERRIDE
;
37 virtual GURL
GetURL() const OVERRIDE
;
40 void OnDataParsed(GDataErrorCode error
, scoped_ptr
<ResourceEntry
> entry
);
42 const GDataWapiUrlGenerator url_generator_
;
43 // Resource id of the requested entry.
44 const std::string resource_id_
;
45 // Embed origin for an url to the sharing dialog. Can be empty.
48 const GetResourceEntryCallback callback_
;
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_
;
54 DISALLOW_COPY_AND_ASSIGN(GetResourceEntryRequest
);
57 } // namespace google_apis
59 #endif // GOOGLE_APIS_DRIVE_GDATA_WAPI_REQUESTS_H_