blob: 05e2796d0ec07d80a4b989e93809feb3f97f01a9 (
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
// Copyright (c) 2011 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/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/message_loop_proxy.h"
#include "base/platform_file.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 FileSystemOperationContext;
class FileSystemQuotaUtil;
class FileWriterDelegate : public net::URLRequest::Delegate {
public:
FileWriterDelegate(
FileSystemOperation* write_operation,
int64 offset,
scoped_refptr<base::MessageLoopProxy> proxy);
virtual ~FileWriterDelegate();
void Start(base::PlatformFile file,
net::URLRequest* request);
base::PlatformFile file() {
return file_;
}
virtual void OnReceivedRedirect(net::URLRequest* request,
const GURL& new_url,
bool* defer_redirect) OVERRIDE;
virtual void OnAuthRequired(net::URLRequest* request,
net::AuthChallengeInfo* auth_info) OVERRIDE;
virtual void OnCertificateRequested(
net::URLRequest* request,
net::SSLCertRequestInfo* cert_request_info) OVERRIDE;
virtual void OnSSLCertificateError(net::URLRequest* request,
const net::SSLInfo& ssl_info,
bool is_hsts_host) OVERRIDE;
virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE;
virtual void OnReadCompleted(net::URLRequest* request,
int bytes_read) OVERRIDE;
private:
void OnGetFileInfoAndCallStartUpdate(
base::PlatformFileError error,
const base::PlatformFileInfo& file_info);
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);
FileSystemOperationContext* file_system_operation_context() const;
FileSystemQuotaUtil* quota_util() const;
FileSystemOperation* file_system_operation_;
base::PlatformFile file_;
int64 size_;
int64 offset_;
scoped_refptr<base::MessageLoopProxy> proxy_;
base::Time last_progress_event_time_;
int bytes_written_backlog_;
int bytes_written_;
int bytes_read_;
int64 total_bytes_written_;
int64 allowed_bytes_to_write_;
scoped_refptr<net::IOBufferWithSize> io_buffer_;
scoped_ptr<net::FileStream> file_stream_;
net::URLRequest* request_;
base::WeakPtrFactory<FileWriterDelegate> weak_factory_;
};
} // namespace fileapi
#endif // WEBKIT_FILEAPI_FILE_WRITER_DELEGATE_H_
|