diff options
author | darin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-29 17:29:38 +0000 |
---|---|---|
committer | darin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-29 17:29:38 +0000 |
commit | 9396b257950a859afb01dea086c13645884e39e4 (patch) | |
tree | ee0c2f81bc9c4f6098ccdb882054a50aff5c6c4f /net/url_request/url_request_file_job.h | |
parent | 1843ebdfbc05e6b91ce4070647271dfbe090d687 (diff) | |
download | chromium_src-9396b257950a859afb01dea086c13645884e39e4.zip chromium_src-9396b257950a859afb01dea086c13645884e39e4.tar.gz chromium_src-9396b257950a859afb01dea086c13645884e39e4.tar.bz2 |
Define FileInputStream and use it to make UpdateDataStream and URLRequestFileJob portable.
file_input_stream_posix.cc is not implemented in this CL. That is saved for a follow-up.
R=mark
Review URL: http://codereview.chromium.org/4101
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2673 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/url_request/url_request_file_job.h')
-rw-r--r-- | net/url_request/url_request_file_job.h | 54 |
1 files changed, 15 insertions, 39 deletions
diff --git a/net/url_request/url_request_file_job.h b/net/url_request/url_request_file_job.h index 638f4ff..92e326c 100644 --- a/net/url_request/url_request_file_job.h +++ b/net/url_request/url_request_file_job.h @@ -5,16 +5,14 @@ #ifndef NET_URL_REQUEST_URL_REQUEST_FILE_JOB_H_ #define NET_URL_REQUEST_URL_REQUEST_FILE_JOB_H_ -#include "base/lock.h" -#include "base/message_loop.h" -#include "base/thread.h" +#include "base/file_util.h" +#include "net/base/completion_callback.h" +#include "net/base/file_input_stream.h" #include "net/url_request/url_request.h" #include "net/url_request/url_request_job.h" -#include "testing/gtest/include/gtest/gtest_prod.h" // A request job that handles reading file URLs -class URLRequestFileJob : public URLRequestJob, - protected MessageLoopForIO::Watcher { +class URLRequestFileJob : public URLRequestJob { public: URLRequestFileJob(URLRequest* request); virtual ~URLRequestFileJob(); @@ -23,13 +21,8 @@ class URLRequestFileJob : public URLRequestJob, virtual void Kill(); virtual bool ReadRawData(char* buf, int buf_size, int *bytes_read); virtual bool IsRedirectResponse(GURL* location, int* http_status_code); - virtual bool GetMimeType(std::string* mime_type); - // Checks the status of the file. Set is_directory_ and is_not_found_ - // accordingly. Call StartAsync on the main message loop when it's done. - void ResolveFile(); - static URLRequest::ProtocolFactory Factory; protected: @@ -37,37 +30,20 @@ class URLRequestFileJob : public URLRequestJob, std::wstring file_path_; private: - // The net util test wants to run our FileURLToFilePath function. - FRIEND_TEST(NetUtilTest, FileURLConversion); - - void CloseHandles(); - void StartAsync(); - - // MessageLoop::Watcher callback - virtual void OnObjectSignaled(HANDLE object); + void DidResolve(bool exists, const file_util::FileInfo& file_info); + void DidRead(int result); - // We use overlapped reads to ensure that reads from network file systems do - // not hang the application thread. - HANDLE handle_; - OVERLAPPED overlapped_; - bool is_waiting_; // true when waiting for overlapped result - bool is_directory_; // true when the file request is for a direcotry. - bool is_not_found_; // true when the file requested does not exist. + net::CompletionCallbackImpl<URLRequestFileJob> io_callback_; + net::FileInputStream stream_; + bool is_directory_; - // This lock ensure that the network_file_thread is not using the loop_ after - // is has been set to NULL in Kill(). - Lock loop_lock_; +#if defined(OS_WIN) + class AsyncResolver; + friend class AsyncResolver; + scoped_refptr<AsyncResolver> async_resolver_; +#endif - // Main message loop where StartAsync has to be called. - MessageLoop* loop_; - - // Thread used to query the attributes of files on the network. - // We need to do it on a separate thread because it can be really - // slow. - HANDLE network_file_thread_; - - DISALLOW_EVIL_CONSTRUCTORS(URLRequestFileJob); + DISALLOW_COPY_AND_ASSIGN(URLRequestFileJob); }; #endif // NET_URL_REQUEST_URL_REQUEST_FILE_JOB_H_ - |