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

Side by Side Diff: sync/internal_api/public/attachments/attachment_service_impl.h

Issue 569463002: Make AttachmentServiceImpl clear backoff when reconnected to network. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with master. Created 6 years, 3 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_SERVICE_IMPL_H_ 5 #ifndef SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_SERVICE_IMPL_H_
6 #define SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_SERVICE_IMPL_H_ 6 #define SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_SERVICE_IMPL_H_
7 7
8 #include <deque> 8 #include <deque>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/threading/non_thread_safe.h" 12 #include "base/threading/non_thread_safe.h"
13 #include "net/base/network_change_notifier.h"
13 #include "sync/api/attachments/attachment_store.h" 14 #include "sync/api/attachments/attachment_store.h"
14 #include "sync/internal_api/public/attachments/attachment_downloader.h" 15 #include "sync/internal_api/public/attachments/attachment_downloader.h"
15 #include "sync/internal_api/public/attachments/attachment_service.h" 16 #include "sync/internal_api/public/attachments/attachment_service.h"
16 #include "sync/internal_api/public/attachments/attachment_service_proxy.h" 17 #include "sync/internal_api/public/attachments/attachment_service_proxy.h"
17 #include "sync/internal_api/public/attachments/attachment_uploader.h" 18 #include "sync/internal_api/public/attachments/attachment_uploader.h"
18 #include "sync/internal_api/public/attachments/task_queue.h" 19 #include "sync/internal_api/public/attachments/task_queue.h"
19 20
20 namespace syncer { 21 namespace syncer {
21 22
22 // Implementation of AttachmentService. 23 // Implementation of AttachmentService.
23 class SYNC_EXPORT AttachmentServiceImpl : public AttachmentService, 24 class SYNC_EXPORT AttachmentServiceImpl
24 public base::NonThreadSafe { 25 : public AttachmentService,
26 public net::NetworkChangeNotifier::NetworkChangeObserver,
27 public base::NonThreadSafe {
25 public: 28 public:
26 // |attachment_uploader| is optional. If null, attachments will never be 29 // |attachment_uploader| is optional. If null, attachments will never be
27 // uploaded to the sync server and |delegate|'s OnAttachmentUploaded will 30 // uploaded to the sync server and |delegate|'s OnAttachmentUploaded will
28 // never be invoked. 31 // never be invoked.
29 // 32 //
30 // |attachment_downloader| is optional. If null, attachments will never be 33 // |attachment_downloader| is optional. If null, attachments will never be
31 // downloaded. Only attachments in |attachment_store| will be returned from 34 // downloaded. Only attachments in |attachment_store| will be returned from
32 // GetOrDownloadAttachments. 35 // GetOrDownloadAttachments.
33 // 36 //
34 // |delegate| is optional delegate for AttachmentService to notify about 37 // |delegate| is optional delegate for AttachmentService to notify about
(...skipping 23 matching lines...) Expand all
58 // AttachmentService implementation. 61 // AttachmentService implementation.
59 virtual AttachmentStore* GetStore() OVERRIDE; 62 virtual AttachmentStore* GetStore() OVERRIDE;
60 virtual void GetOrDownloadAttachments( 63 virtual void GetOrDownloadAttachments(
61 const AttachmentIdList& attachment_ids, 64 const AttachmentIdList& attachment_ids,
62 const GetOrDownloadCallback& callback) OVERRIDE; 65 const GetOrDownloadCallback& callback) OVERRIDE;
63 virtual void DropAttachments(const AttachmentIdList& attachment_ids, 66 virtual void DropAttachments(const AttachmentIdList& attachment_ids,
64 const DropCallback& callback) OVERRIDE; 67 const DropCallback& callback) OVERRIDE;
65 virtual void UploadAttachments( 68 virtual void UploadAttachments(
66 const AttachmentIdSet& attachment_ids) OVERRIDE; 69 const AttachmentIdSet& attachment_ids) OVERRIDE;
67 70
71 // NetworkChangeObserver implementation.
72 virtual void OnNetworkChanged(
73 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE;
74
75 // Use |timer| in the underlying TaskQueue.
76 //
77 // Used in tests. See also MockTimer.
78 void SetTimerForTest(scoped_ptr<base::Timer> timer);
79
68 private: 80 private:
69 class GetOrDownloadState; 81 class GetOrDownloadState;
70 82
71 void ReadDone(const scoped_refptr<GetOrDownloadState>& state, 83 void ReadDone(const scoped_refptr<GetOrDownloadState>& state,
72 const AttachmentStore::Result& result, 84 const AttachmentStore::Result& result,
73 scoped_ptr<AttachmentMap> attachments, 85 scoped_ptr<AttachmentMap> attachments,
74 scoped_ptr<AttachmentIdList> unavailable_attachment_ids); 86 scoped_ptr<AttachmentIdList> unavailable_attachment_ids);
75 void DropDone(const DropCallback& callback, 87 void DropDone(const DropCallback& callback,
76 const AttachmentStore::Result& result); 88 const AttachmentStore::Result& result);
77 void UploadDone(const AttachmentUploader::UploadResult& result, 89 void UploadDone(const AttachmentUploader::UploadResult& result,
(...skipping 23 matching lines...) Expand all
101 113
102 // Must be last data member. 114 // Must be last data member.
103 base::WeakPtrFactory<AttachmentServiceImpl> weak_ptr_factory_; 115 base::WeakPtrFactory<AttachmentServiceImpl> weak_ptr_factory_;
104 116
105 DISALLOW_COPY_AND_ASSIGN(AttachmentServiceImpl); 117 DISALLOW_COPY_AND_ASSIGN(AttachmentServiceImpl);
106 }; 118 };
107 119
108 } // namespace syncer 120 } // namespace syncer
109 121
110 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_SERVICE_IMPL_H_ 122 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_SERVICE_IMPL_H_
OLDNEW
« no previous file with comments | « sync/internal_api/attachments/task_queue_unittest.cc ('k') | sync/internal_api/public/attachments/task_queue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698