Update AttachmentServiceImpl to retry attachment uploads.
[chromium-blink-merge.git] / sync / internal_api / public / attachments / attachment_downloader.h
blob12db4225c08f6d0d337c5dfa5ac07632355fcfef
1 // Copyright 2014 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 SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_DOWNLOADER_H_
6 #define SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_DOWNLOADER_H_
8 #include "base/callback.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "google_apis/gaia/oauth2_token_service_request.h"
11 #include "sync/api/attachments/attachment.h"
12 #include "sync/base/sync_export.h"
14 namespace net {
15 class URLRequestContextGetter;
16 } // namespace net
18 namespace syncer {
20 // AttachmentDownloader is responsible for downloading attachments from server.
21 class SYNC_EXPORT AttachmentDownloader {
22 public:
23 // The result of a DownloadAttachment operation.
24 enum DownloadResult {
25 DOWNLOAD_SUCCESS, // No error, attachment was downloaded
26 // successfully.
27 DOWNLOAD_TRANSIENT_ERROR, // A transient error occurred, try again later.
28 DOWNLOAD_UNSPECIFIED_ERROR, // An unspecified error occurred.
31 typedef base::Callback<void(const DownloadResult&, scoped_ptr<Attachment>)>
32 DownloadCallback;
34 virtual ~AttachmentDownloader();
36 // Download attachment referred by |attachment_id| and invoke |callback| when
37 // done.
39 // |callback| will receive a DownloadResult code and an Attachment object. If
40 // DownloadResult is not DOWNLOAD_SUCCESS then attachment pointer is NULL.
41 virtual void DownloadAttachment(const AttachmentId& attachment_id,
42 const DownloadCallback& callback) = 0;
44 // Create instance of AttachmentDownloaderImpl.
45 // |sync_service_url| is the URL of the sync service.
47 // |url_request_context_getter| provides a URLRequestContext.
49 // |account_id| is the account id to use for downloads.
51 // |scopes| is the set of scopes to use for downloads.
53 // |token_service_provider| provides an OAuth2 token service.
54 static scoped_ptr<AttachmentDownloader> Create(
55 const GURL& sync_service_url,
56 const scoped_refptr<net::URLRequestContextGetter>&
57 url_request_context_getter,
58 const std::string& account_id,
59 const OAuth2TokenService::ScopeSet scopes,
60 const scoped_refptr<OAuth2TokenServiceRequest::TokenServiceProvider>&
61 token_service_provider);
64 } // namespace syncer
66 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_DOWNLOADER_H_