| 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 #ifndef STORAGE_BROWSER_FILEAPI_FILE_WRITER_DELEGATE_H_ | 5 #ifndef STORAGE_BROWSER_FILEAPI_FILE_WRITER_DELEGATE_H_ |
| 6 #define STORAGE_BROWSER_FILEAPI_FILE_WRITER_DELEGATE_H_ | 6 #define STORAGE_BROWSER_FILEAPI_FILE_WRITER_DELEGATE_H_ |
| 7 | 7 |
| 8 #include "base/files/file.h" | 8 #include "base/files/file.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 ERROR_WRITE_NOT_STARTED, | 34 ERROR_WRITE_NOT_STARTED, |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 typedef base::Callback<void(base::File::Error result, | 37 typedef base::Callback<void(base::File::Error result, |
| 38 int64 bytes, | 38 int64 bytes, |
| 39 WriteProgressStatus write_status)> | 39 WriteProgressStatus write_status)> |
| 40 DelegateWriteCallback; | 40 DelegateWriteCallback; |
| 41 | 41 |
| 42 FileWriterDelegate(scoped_ptr<FileStreamWriter> file_writer, | 42 FileWriterDelegate(scoped_ptr<FileStreamWriter> file_writer, |
| 43 FlushPolicy flush_policy); | 43 FlushPolicy flush_policy); |
| 44 virtual ~FileWriterDelegate(); | 44 ~FileWriterDelegate() override; |
| 45 | 45 |
| 46 void Start(scoped_ptr<net::URLRequest> request, | 46 void Start(scoped_ptr<net::URLRequest> request, |
| 47 const DelegateWriteCallback& write_callback); | 47 const DelegateWriteCallback& write_callback); |
| 48 | 48 |
| 49 // Cancels the current write operation. This will synchronously or | 49 // Cancels the current write operation. This will synchronously or |
| 50 // asynchronously call the given write callback (which may result in | 50 // asynchronously call the given write callback (which may result in |
| 51 // deleting this). | 51 // deleting this). |
| 52 void Cancel(); | 52 void Cancel(); |
| 53 | 53 |
| 54 virtual void OnReceivedRedirect(net::URLRequest* request, | 54 void OnReceivedRedirect(net::URLRequest* request, |
| 55 const net::RedirectInfo& redirect_info, | 55 const net::RedirectInfo& redirect_info, |
| 56 bool* defer_redirect) override; | 56 bool* defer_redirect) override; |
| 57 virtual void OnAuthRequired(net::URLRequest* request, | 57 void OnAuthRequired(net::URLRequest* request, |
| 58 net::AuthChallengeInfo* auth_info) override; | 58 net::AuthChallengeInfo* auth_info) override; |
| 59 virtual void OnCertificateRequested( | 59 void OnCertificateRequested( |
| 60 net::URLRequest* request, | 60 net::URLRequest* request, |
| 61 net::SSLCertRequestInfo* cert_request_info) override; | 61 net::SSLCertRequestInfo* cert_request_info) override; |
| 62 virtual void OnSSLCertificateError(net::URLRequest* request, | 62 void OnSSLCertificateError(net::URLRequest* request, |
| 63 const net::SSLInfo& ssl_info, | 63 const net::SSLInfo& ssl_info, |
| 64 bool fatal) override; | 64 bool fatal) override; |
| 65 virtual void OnResponseStarted(net::URLRequest* request) override; | 65 void OnResponseStarted(net::URLRequest* request) override; |
| 66 virtual void OnReadCompleted(net::URLRequest* request, | 66 void OnReadCompleted(net::URLRequest* request, int bytes_read) override; |
| 67 int bytes_read) override; | |
| 68 | 67 |
| 69 private: | 68 private: |
| 70 void OnGetFileInfoAndStartRequest( | 69 void OnGetFileInfoAndStartRequest( |
| 71 scoped_ptr<net::URLRequest> request, | 70 scoped_ptr<net::URLRequest> request, |
| 72 base::File::Error error, | 71 base::File::Error error, |
| 73 const base::File::Info& file_info); | 72 const base::File::Info& file_info); |
| 74 void Read(); | 73 void Read(); |
| 75 void OnDataReceived(int bytes_read); | 74 void OnDataReceived(int bytes_read); |
| 76 void Write(); | 75 void Write(); |
| 77 void OnDataWritten(int write_response); | 76 void OnDataWritten(int write_response); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 101 scoped_ptr<net::URLRequest> request_; | 100 scoped_ptr<net::URLRequest> request_; |
| 102 | 101 |
| 103 base::WeakPtrFactory<FileWriterDelegate> weak_factory_; | 102 base::WeakPtrFactory<FileWriterDelegate> weak_factory_; |
| 104 | 103 |
| 105 DISALLOW_COPY_AND_ASSIGN(FileWriterDelegate); | 104 DISALLOW_COPY_AND_ASSIGN(FileWriterDelegate); |
| 106 }; | 105 }; |
| 107 | 106 |
| 108 } // namespace storage | 107 } // namespace storage |
| 109 | 108 |
| 110 #endif // STORAGE_BROWSER_FILEAPI_FILE_WRITER_DELEGATE_H_ | 109 #endif // STORAGE_BROWSER_FILEAPI_FILE_WRITER_DELEGATE_H_ |
| OLD | NEW |