1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef NET_URL_REQUEST_URL_REQUEST_FTP_JOB_H_
6 #define NET_URL_REQUEST_URL_REQUEST_FTP_JOB_H_
11 #include "base/memory/weak_ptr.h"
12 #include "net/base/auth.h"
13 #include "net/base/completion_callback.h"
14 #include "net/ftp/ftp_request_info.h"
15 #include "net/ftp/ftp_transaction.h"
16 #include "net/url_request/url_request_job.h"
20 class URLRequestContext
;
22 // A URLRequestJob subclass that is built on top of FtpTransaction. It
23 // provides an implementation for FTP.
24 class URLRequestFtpJob
: public URLRequestJob
{
26 explicit URLRequestFtpJob(URLRequest
* request
);
28 static URLRequestJob
* Factory(URLRequest
* request
,
29 const std::string
& scheme
);
31 // Overridden from URLRequestJob:
32 virtual bool GetMimeType(std::string
* mime_type
) const OVERRIDE
;
33 virtual HostPortPair
GetSocketAddress() const OVERRIDE
;
36 virtual ~URLRequestFtpJob();
38 void StartTransaction();
40 void OnStartCompleted(int result
);
41 void OnReadCompleted(int result
);
43 void RestartTransactionWithAuth();
45 void LogFtpServerType(char server_type
);
47 // Overridden from URLRequestJob:
48 virtual void Start() OVERRIDE
;
49 virtual void Kill() OVERRIDE
;
50 virtual LoadState
GetLoadState() const OVERRIDE
;
51 virtual bool NeedsAuth() OVERRIDE
;
52 virtual void GetAuthChallengeInfo(
53 scoped_refptr
<AuthChallengeInfo
>* auth_info
) OVERRIDE
;
54 virtual void SetAuth(const AuthCredentials
& credentials
) OVERRIDE
;
55 virtual void CancelAuth() OVERRIDE
;
57 // TODO(ibrar): Yet to give another look at this function.
58 virtual uint64
GetUploadProgress() const OVERRIDE
;
59 virtual bool ReadRawData(IOBuffer
* buf
,
61 int *bytes_read
) OVERRIDE
;
63 FtpRequestInfo request_info_
;
64 scoped_ptr
<FtpTransaction
> transaction_
;
66 bool read_in_progress_
;
68 scoped_refptr
<AuthData
> server_auth_
;
70 // Keep a reference to the url request context to be sure it's not deleted
72 scoped_refptr
<const URLRequestContext
> context_
;
74 base::WeakPtrFactory
<URLRequestFtpJob
> weak_factory_
;
76 DISALLOW_COPY_AND_ASSIGN(URLRequestFtpJob
);
81 #endif // NET_URL_REQUEST_URL_REQUEST_FTP_JOB_H_