OLD | NEW |
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 #include "sync/internal_api/public/attachments/attachment_uploader_impl.h" | 5 #include "sync/internal_api/public/attachments/attachment_uploader_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/threading/non_thread_safe.h" | 10 #include "base/threading/non_thread_safe.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // completed. | 59 // completed. |
60 // | 60 // |
61 // It is an error to call |AddUserCallback| on a stopped UploadState (see | 61 // It is an error to call |AddUserCallback| on a stopped UploadState (see |
62 // |IsStopped|). | 62 // |IsStopped|). |
63 void AddUserCallback(const UploadCallback& user_callback); | 63 void AddUserCallback(const UploadCallback& user_callback); |
64 | 64 |
65 // Return the Attachment this object is uploading. | 65 // Return the Attachment this object is uploading. |
66 const Attachment& GetAttachment(); | 66 const Attachment& GetAttachment(); |
67 | 67 |
68 // URLFetcher implementation. | 68 // URLFetcher implementation. |
69 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 69 virtual void OnURLFetchComplete(const net::URLFetcher* source) override; |
70 | 70 |
71 // OAuth2TokenService::Consumer. | 71 // OAuth2TokenService::Consumer. |
72 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, | 72 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, |
73 const std::string& access_token, | 73 const std::string& access_token, |
74 const base::Time& expiration_time) OVERRIDE; | 74 const base::Time& expiration_time) override; |
75 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, | 75 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, |
76 const GoogleServiceAuthError& error) OVERRIDE; | 76 const GoogleServiceAuthError& error) override; |
77 | 77 |
78 private: | 78 private: |
79 typedef std::vector<UploadCallback> UploadCallbackList; | 79 typedef std::vector<UploadCallback> UploadCallbackList; |
80 | 80 |
81 void GetToken(); | 81 void GetToken(); |
82 | 82 |
83 void StopAndReportResult(const UploadResult& result, | 83 void StopAndReportResult(const UploadResult& result, |
84 const AttachmentId& attachment_id); | 84 const AttachmentId& attachment_id); |
85 | 85 |
86 bool is_stopped_; | 86 bool is_stopped_; |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 // Only erase if stopped. Because this method is called asynchronously, it's | 328 // Only erase if stopped. Because this method is called asynchronously, it's |
329 // possible that a new request for this same id arrived after the UploadState | 329 // possible that a new request for this same id arrived after the UploadState |
330 // stopped, but before this method was invoked. In that case the UploadState | 330 // stopped, but before this method was invoked. In that case the UploadState |
331 // in the map might be a new one. | 331 // in the map might be a new one. |
332 if (iter != state_map_.end() && iter->second->IsStopped()) { | 332 if (iter != state_map_.end() && iter->second->IsStopped()) { |
333 state_map_.erase(iter); | 333 state_map_.erase(iter); |
334 } | 334 } |
335 } | 335 } |
336 | 336 |
337 } // namespace syncer | 337 } // namespace syncer |
OLD | NEW |