• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2009 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.
4 
5 #ifndef NET_URL_REQUEST_URL_REQUEST_NEW_FTP_JOB_H_
6 #define NET_URL_REQUEST_URL_REQUEST_NEW_FTP_JOB_H_
7 
8 #include <string>
9 
10 #include "net/base/auth.h"
11 #include "net/base/completion_callback.h"
12 #include "net/ftp/ftp_request_info.h"
13 #include "net/ftp/ftp_transaction.h"
14 #include "net/url_request/url_request_job.h"
15 
16 class URLRequestContext;
17 
18 namespace net {
19 struct list_state;
20 }
21 
22 // A URLRequestJob subclass that is built on top of FtpTransaction. It
23 // provides an implementation for FTP.
24 class URLRequestNewFtpJob : public URLRequestJob {
25  public:
26 
27   explicit URLRequestNewFtpJob(URLRequest* request);
28 
29   static URLRequestJob* Factory(URLRequest* request, const std::string& scheme);
30 
31   // URLRequestJob methods:
32   virtual bool GetMimeType(std::string* mime_type) const;
33 
34  private:
35   virtual ~URLRequestNewFtpJob();
36 
37   // URLRequestJob methods:
38   virtual void Start();
39   virtual void Kill();
40   virtual net::LoadState GetLoadState() const;
41   virtual bool NeedsAuth();
42   virtual void GetAuthChallengeInfo(
43       scoped_refptr<net::AuthChallengeInfo>* auth_info);
44   virtual void SetAuth(const std::wstring& username,
45                        const std::wstring& password);
46   virtual void CancelAuth();
47 
48   // TODO(ibrar):  Yet to give another look at this function.
GetUploadProgress()49   virtual uint64 GetUploadProgress() const { return 0; }
50   virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int *bytes_read);
51 
52   void DestroyTransaction();
53   void StartTransaction();
54 
55   void OnStartCompleted(int result);
56   void OnReadCompleted(int result);
57 
58   void RestartTransactionWithAuth();
59 
60   void LogFtpServerType(char server_type);
61 
62   net::FtpRequestInfo request_info_;
63   scoped_ptr<net::FtpTransaction> transaction_;
64 
65   net::CompletionCallbackImpl<URLRequestNewFtpJob> start_callback_;
66   net::CompletionCallbackImpl<URLRequestNewFtpJob> read_callback_;
67 
68   bool read_in_progress_;
69 
70   scoped_refptr<net::AuthData> server_auth_;
71 
72   // Keep a reference to the url request context to be sure it's not deleted
73   // before us.
74   scoped_refptr<URLRequestContext> context_;
75 
76   DISALLOW_COPY_AND_ASSIGN(URLRequestNewFtpJob);
77 };
78 
79 #endif  // NET_URL_REQUEST_URL_REQUEST_NEW_FTP_JOB_H_
80