blob: 3b053c1e190ab61823a43babecdd196151b4807d (
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
// Copyright (c) 2012 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 NET_URL_REQUEST_URL_REQUEST_FTP_JOB_H_
#define NET_URL_REQUEST_URL_REQUEST_FTP_JOB_H_
#include <string>
#include "base/memory/weak_ptr.h"
#include "net/base/auth.h"
#include "net/ftp/ftp_request_info.h"
#include "net/ftp/ftp_transaction.h"
#include "net/http/http_request_info.h"
#include "net/http/http_transaction.h"
#include "net/proxy/proxy_info.h"
#include "net/proxy/proxy_service.h"
#include "net/url_request/url_request_job.h"
namespace net {
class NetworkDelegate;
class FtpTransactionFactory;
class FtpAuthCache;
// A URLRequestJob subclass that is built on top of FtpTransaction. It
// provides an implementation for FTP.
class URLRequestFtpJob : public URLRequestJob {
public:
URLRequestFtpJob(URLRequest* request,
NetworkDelegate* network_delegate,
FtpTransactionFactory* ftp_transaction_factory,
FtpAuthCache* ftp_auth_cache);
// TODO(shalev): get rid of this function in favor of FtpProtocolHandler.
static URLRequestJob* Factory(URLRequest* request,
NetworkDelegate* network_delegate,
const std::string& scheme);
// Overridden from URLRequestJob:
virtual bool IsSafeRedirect(const GURL& location) OVERRIDE;
virtual bool GetMimeType(std::string* mime_type) const OVERRIDE;
virtual void GetResponseInfo(HttpResponseInfo* info) OVERRIDE;
virtual HostPortPair GetSocketAddress() const OVERRIDE;
private:
virtual ~URLRequestFtpJob();
void OnResolveProxyComplete(int result);
void StartFtpTransaction();
void StartHttpTransaction();
void OnStartCompleted(int result);
void OnStartCompletedAsync(int result);
void OnReadCompleted(int result);
void RestartTransactionWithAuth();
void LogFtpServerType(char server_type);
// Overridden from URLRequestJob:
virtual void Start() OVERRIDE;
virtual void Kill() OVERRIDE;
virtual LoadState GetLoadState() const OVERRIDE;
virtual bool NeedsAuth() OVERRIDE;
virtual void GetAuthChallengeInfo(
scoped_refptr<AuthChallengeInfo>* auth_info) OVERRIDE;
virtual void SetAuth(const AuthCredentials& credentials) OVERRIDE;
virtual void CancelAuth() OVERRIDE;
// TODO(ibrar): Yet to give another look at this function.
virtual UploadProgress GetUploadProgress() const OVERRIDE;
virtual bool ReadRawData(IOBuffer* buf,
int buf_size,
int *bytes_read) OVERRIDE;
ProxyInfo proxy_info_;
ProxyService::PacRequest* pac_request_;
FtpRequestInfo ftp_request_info_;
scoped_ptr<FtpTransaction> ftp_transaction_;
HttpRequestInfo http_request_info_;
scoped_ptr<HttpTransaction> http_transaction_;
const HttpResponseInfo* response_info_;
bool read_in_progress_;
scoped_refptr<AuthData> server_auth_;
base::WeakPtrFactory<URLRequestFtpJob> weak_factory_;
FtpTransactionFactory* ftp_transaction_factory_;
FtpAuthCache* ftp_auth_cache_;
DISALLOW_COPY_AND_ASSIGN(URLRequestFtpJob);
};
} // namespace net
#endif // NET_URL_REQUEST_URL_REQUEST_FTP_JOB_H_
|