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/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/threading/non_thread_safe.h" | 9 #include "base/threading/non_thread_safe.h" |
10 #include "google_apis/gaia/gaia_constants.h" | 10 #include "google_apis/gaia/gaia_constants.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 return attachment_; | 130 return attachment_; |
131 } | 131 } |
132 | 132 |
133 void AttachmentUploaderImpl::UploadState::OnURLFetchComplete( | 133 void AttachmentUploaderImpl::UploadState::OnURLFetchComplete( |
134 const net::URLFetcher* source) { | 134 const net::URLFetcher* source) { |
135 DCHECK(CalledOnValidThread()); | 135 DCHECK(CalledOnValidThread()); |
136 UploadResult result = UPLOAD_UNSPECIFIED_ERROR; | 136 UploadResult result = UPLOAD_UNSPECIFIED_ERROR; |
137 AttachmentId attachment_id = attachment_.GetId(); | 137 AttachmentId attachment_id = attachment_.GetId(); |
138 if (source->GetResponseCode() == net::HTTP_OK) { | 138 if (source->GetResponseCode() == net::HTTP_OK) { |
139 result = UPLOAD_SUCCESS; | 139 result = UPLOAD_SUCCESS; |
140 // TODO(maniscalco): Update the attachment id with server address | |
141 // information before passing it to the callback (bug 371522). | |
142 } else if (source->GetResponseCode() == net::HTTP_UNAUTHORIZED) { | 140 } else if (source->GetResponseCode() == net::HTTP_UNAUTHORIZED) { |
143 // TODO(maniscalco): One possibility is that we received a 401 because our | 141 // TODO(maniscalco): One possibility is that we received a 401 because our |
144 // access token has expired. We should probably fetch a new access token | 142 // access token has expired. We should probably fetch a new access token |
145 // and retry this upload before giving up and reporting failure to our | 143 // and retry this upload before giving up and reporting failure to our |
146 // caller (bug 380437). | 144 // caller (bug 380437). |
147 OAuth2TokenServiceRequest::InvalidateToken( | 145 OAuth2TokenServiceRequest::InvalidateToken( |
148 token_service_provider_, account_id_, scopes_, access_token_); | 146 token_service_provider_, account_id_, scopes_, access_token_); |
149 } else { | 147 } else { |
150 // TODO(maniscalco): Once the protocol is better defined, deal with the | 148 // TODO(maniscalco): Once the protocol is better defined, deal with the |
151 // various HTTP response codes we may encounter. | 149 // various HTTP response codes we may encounter. |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 GURL::Replacements replacements; | 269 GURL::Replacements replacements; |
272 replacements.SetPathStr(path); | 270 replacements.SetPathStr(path); |
273 return sync_service_url.ReplaceComponents(replacements); | 271 return sync_service_url.ReplaceComponents(replacements); |
274 } | 272 } |
275 | 273 |
276 void AttachmentUploaderImpl::DeleteUploadStateFor(const UniqueId& unique_id) { | 274 void AttachmentUploaderImpl::DeleteUploadStateFor(const UniqueId& unique_id) { |
277 state_map_.erase(unique_id); | 275 state_map_.erase(unique_id); |
278 } | 276 } |
279 | 277 |
280 } // namespace syncer | 278 } // namespace syncer |
OLD | NEW |