Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / sync / internal_api / public / attachments / attachment_downloader.h
blob1b2e922eefe49f95d5132e1b99ba3283b5df4bbb
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"
13 #include "sync/internal_api/public/base/model_type.h"
15 namespace net {
16 class URLRequestContextGetter;
17 } // namespace net
19 namespace syncer {
21 // AttachmentDownloader is responsible for downloading attachments from server.
22 class SYNC_EXPORT AttachmentDownloader {
23 public:
24 // The result of a DownloadAttachment operation.
25 enum DownloadResult {
26 DOWNLOAD_SUCCESS, // No error, attachment was downloaded
27 // successfully.
28 DOWNLOAD_TRANSIENT_ERROR, // A transient error occurred, try again later.
29 DOWNLOAD_UNSPECIFIED_ERROR, // An unspecified error occurred.
32 typedef base::Callback<void(const DownloadResult&, scoped_ptr<Attachment>)>
33 DownloadCallback;
35 virtual ~AttachmentDownloader();
37 // Download attachment referred by |attachment_id| and invoke |callback| when
38 // done.
40 // |callback| will receive a DownloadResult code and an Attachment object. If
41 // DownloadResult is not DOWNLOAD_SUCCESS then attachment pointer is NULL.
42 virtual void DownloadAttachment(const AttachmentId& attachment_id,
43 const DownloadCallback& callback) = 0;
45 // Create instance of AttachmentDownloaderImpl.
46 // |sync_service_url| is the URL of the sync service.
48 // |url_request_context_getter| provides a URLRequestContext.
50 // |account_id| is the account id to use for downloads.
52 // |scopes| is the set of scopes to use for downloads.
54 // |token_service_provider| provides an OAuth2 token service.
56 // |store_birthday| is the raw, sync store birthday.
58 // |model_type| is the model type this downloader is used with.
59 static scoped_ptr<AttachmentDownloader> Create(
60 const GURL& sync_service_url,
61 const scoped_refptr<net::URLRequestContextGetter>&
62 url_request_context_getter,
63 const std::string& account_id,
64 const OAuth2TokenService::ScopeSet scopes,
65 const scoped_refptr<OAuth2TokenServiceRequest::TokenServiceProvider>&
66 token_service_provider,
67 const std::string& store_birthday,
68 ModelType model_type);
71 } // namespace syncer
73 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_DOWNLOADER_H_