OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "storage/browser/fileapi/file_writer_delegate.h" | 5 #include "storage/browser/fileapi/file_writer_delegate.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/files/file_util_proxy.h" | 9 #include "base/files/file_util_proxy.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "base/message_loop/message_loop_proxy.h" | 11 #include "base/message_loop/message_loop_proxy.h" |
| 12 #include "base/profiler/scoped_tracker.h" |
12 #include "base/sequenced_task_runner.h" | 13 #include "base/sequenced_task_runner.h" |
13 #include "base/threading/thread_restrictions.h" | 14 #include "base/threading/thread_restrictions.h" |
14 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
15 #include "storage/browser/fileapi/file_stream_writer.h" | 16 #include "storage/browser/fileapi/file_stream_writer.h" |
16 #include "storage/browser/fileapi/file_system_context.h" | 17 #include "storage/browser/fileapi/file_system_context.h" |
17 #include "storage/common/fileapi/file_system_util.h" | 18 #include "storage/common/fileapi/file_system_util.h" |
18 | 19 |
19 namespace storage { | 20 namespace storage { |
20 | 21 |
21 static const int kReadBufSize = 32768; | 22 static const int kReadBufSize = 32768; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 } | 84 } |
84 | 85 |
85 void FileWriterDelegate::OnSSLCertificateError(net::URLRequest* request, | 86 void FileWriterDelegate::OnSSLCertificateError(net::URLRequest* request, |
86 const net::SSLInfo& ssl_info, | 87 const net::SSLInfo& ssl_info, |
87 bool fatal) { | 88 bool fatal) { |
88 NOTREACHED(); | 89 NOTREACHED(); |
89 OnError(base::File::FILE_ERROR_SECURITY); | 90 OnError(base::File::FILE_ERROR_SECURITY); |
90 } | 91 } |
91 | 92 |
92 void FileWriterDelegate::OnResponseStarted(net::URLRequest* request) { | 93 void FileWriterDelegate::OnResponseStarted(net::URLRequest* request) { |
| 94 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed. |
| 95 tracked_objects::ScopedTracker tracking_profile( |
| 96 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 97 "423948 FileWriterDelegate::OnResponseStarted")); |
| 98 |
93 DCHECK_EQ(request_.get(), request); | 99 DCHECK_EQ(request_.get(), request); |
94 if (!request->status().is_success() || request->GetResponseCode() != 200) { | 100 if (!request->status().is_success() || request->GetResponseCode() != 200) { |
95 OnError(base::File::FILE_ERROR_FAILED); | 101 OnError(base::File::FILE_ERROR_FAILED); |
96 return; | 102 return; |
97 } | 103 } |
98 Read(); | 104 Read(); |
99 } | 105 } |
100 | 106 |
101 void FileWriterDelegate::OnReadCompleted(net::URLRequest* request, | 107 void FileWriterDelegate::OnReadCompleted(net::URLRequest* request, |
102 int bytes_read) { | 108 int bytes_read) { |
| 109 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed. |
| 110 tracked_objects::ScopedTracker tracking_profile( |
| 111 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 112 "423948 FileWriterDelegate::OnReadCompleted")); |
| 113 |
103 DCHECK_EQ(request_.get(), request); | 114 DCHECK_EQ(request_.get(), request); |
104 if (!request->status().is_success()) { | 115 if (!request->status().is_success()) { |
105 OnError(base::File::FILE_ERROR_FAILED); | 116 OnError(base::File::FILE_ERROR_FAILED); |
106 return; | 117 return; |
107 } | 118 } |
108 OnDataReceived(bytes_read); | 119 OnDataReceived(bytes_read); |
109 } | 120 } |
110 | 121 |
111 void FileWriterDelegate::Read() { | 122 void FileWriterDelegate::Read() { |
112 bytes_written_ = 0; | 123 bytes_written_ = 0; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 if (error == base::File::FILE_OK && flush_error != net::OK) { | 246 if (error == base::File::FILE_OK && flush_error != net::OK) { |
236 // If the Flush introduced an error, overwrite the status. | 247 // If the Flush introduced an error, overwrite the status. |
237 // Otherwise, keep the original error status. | 248 // Otherwise, keep the original error status. |
238 error = NetErrorToFileError(flush_error); | 249 error = NetErrorToFileError(flush_error); |
239 progress_status = GetCompletionStatusOnError(); | 250 progress_status = GetCompletionStatusOnError(); |
240 } | 251 } |
241 write_callback_.Run(error, bytes_written, progress_status); | 252 write_callback_.Run(error, bytes_written, progress_status); |
242 } | 253 } |
243 | 254 |
244 } // namespace storage | 255 } // namespace storage |
OLD | NEW |