blob: ed35ce618af258614c8d3ec111be3319f00b8c6e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_FILEAPI_FILE_WRITER_DELEGATE_H_
#define WEBKIT_FILEAPI_FILE_WRITER_DELEGATE_H_
#include "base/file_path.h"
#include "base/platform_file.h"
#include "base/ref_counted.h"
#include "base/scoped_callback_factory.h"
#include "base/scoped_ptr.h"
#include "base/task.h"
#include "base/time.h"
#include "net/base/file_stream.h"
#include "net/base/io_buffer.h"
#include "net/url_request/url_request.h"
namespace fileapi {
class FileSystemOperation;
class FileWriterDelegate : public URLRequest::Delegate {
public:
FileWriterDelegate(
FileSystemOperation* write_operation,
int64 offset);
virtual ~FileWriterDelegate();
void Start(base::PlatformFile file, URLRequest* request);
base::PlatformFile file() {
return file_;
}
virtual void OnReceivedRedirect(
URLRequest* request, const GURL& new_url, bool* defer_redirect);
virtual void OnAuthRequired(
URLRequest* request, net::AuthChallengeInfo* auth_info);
virtual void OnCertificateRequested(
URLRequest* request, net::SSLCertRequestInfo* cert_request_info);
virtual void OnSSLCertificateError(
URLRequest* request, int cert_error, net::X509Certificate* cert);
virtual void OnResponseStarted(URLRequest* request);
virtual void OnReadCompleted(URLRequest* request, int bytes_read);
private:
void Read();
void OnDataReceived(int bytes_read);
void Write();
void OnDataWritten(int write_response);
void OnError(base::PlatformFileError error);
void OnProgress(int bytes_read, bool done);
FileSystemOperation* file_system_operation_;
base::PlatformFile file_;
int64 offset_;
base::Time last_progress_event_time_;
int bytes_read_backlog_;
int bytes_written_;
int bytes_read_;
scoped_refptr<net::IOBufferWithSize> io_buffer_;
scoped_ptr<net::FileStream> file_stream_;
URLRequest* request_;
base::ScopedCallbackFactory<FileWriterDelegate> callback_factory_;
ScopedRunnableMethodFactory<FileWriterDelegate> method_factory_;
};
} // namespace fileapi
#endif // WEBKIT_FILEAPI_FILE_WRITER_DELEGATE_H_
|