diff options
author | darin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-04 20:12:18 +0000 |
---|---|---|
committer | darin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-04 20:12:18 +0000 |
commit | b61e30dff7d2dba5be886e837c9371682efc8ced (patch) | |
tree | 9a281cb9d154c46f1bd34b660d38ee8ff1ca1d7a /net/url_request | |
parent | 467d8a78689a19aaa96c6700eb02dd94cac5eae1 (diff) | |
download | chromium_src-b61e30dff7d2dba5be886e837c9371682efc8ced.zip chromium_src-b61e30dff7d2dba5be886e837c9371682efc8ced.tar.gz chromium_src-b61e30dff7d2dba5be886e837c9371682efc8ced.tar.bz2 |
Use base::ObjectWatcher instead of MessageLoop::WatchObject for some consumers in the net module.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@335 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/url_request')
-rw-r--r-- | net/url_request/url_request_file_job.cc | 11 | ||||
-rw-r--r-- | net/url_request/url_request_file_job.h | 17 |
2 files changed, 13 insertions, 15 deletions
diff --git a/net/url_request/url_request_file_job.cc b/net/url_request/url_request_file_job.cc index a738b3a..9f828d4 100644 --- a/net/url_request/url_request_file_job.cc +++ b/net/url_request/url_request_file_job.cc @@ -40,7 +40,7 @@ // attempts to read more from the file to fill its buffer. If reading from the // file does not complete synchronously, then the URLRequestFileJob waits for a // signal from the OS that the overlapped read has completed. It does so by -// leveraging the MessageLoop::WatchObject API. +// leveraging the ObjectWatcher API. #include <process.h> #include <windows.h> @@ -57,6 +57,7 @@ #include "net/url_request/url_request.h" #include "net/url_request/url_request_file_dir_job.h" +// TODO(darin): The file job should not depend on WinInet!! using net::WinInetUtil; namespace { @@ -165,7 +166,7 @@ void URLRequestFileJob::Start() { void URLRequestFileJob::Kill() { // If we are killed while waiting for an overlapped result... if (is_waiting_) { - MessageLoop::current()->WatchObject(overlapped_.hEvent, NULL); + watcher_.StopWatching(); is_waiting_ = false; Release(); } @@ -203,7 +204,7 @@ bool URLRequestFileJob::ReadRawData(char* dest, int dest_size, DWORD err = GetLastError(); if (err == ERROR_IO_PENDING) { // OK, wait for the object to become signaled - MessageLoop::current()->WatchObject(overlapped_.hEvent, this); + watcher_.StartWatching(overlapped_.hEvent, this); is_waiting_ = true; SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0)); AddRef(); @@ -284,9 +285,7 @@ void URLRequestFileJob::OnObjectSignaled(HANDLE object) { DCHECK(overlapped_.hEvent == object); DCHECK(is_waiting_); - // We'll resume watching this handle if need be when we do - // another IO. - MessageLoop::current()->WatchObject(object, NULL); + // We'll resume watching this handle if need be when we do another IO. is_waiting_ = false; DWORD bytes_read = 0; diff --git a/net/url_request/url_request_file_job.h b/net/url_request/url_request_file_job.h index 1851444..d5e63fb 100644 --- a/net/url_request/url_request_file_job.h +++ b/net/url_request/url_request_file_job.h @@ -27,11 +27,12 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef BASE_URL_REQUEST_URL_REQUEST_FILE_JOB_H__ -#define BASE_URL_REQUEST_URL_REQUEST_FILE_JOB_H__ +#ifndef BASE_URL_REQUEST_URL_REQUEST_FILE_JOB_H_ +#define BASE_URL_REQUEST_URL_REQUEST_FILE_JOB_H_ #include "base/lock.h" #include "base/message_loop.h" +#include "base/object_watcher.h" #include "base/thread.h" #include "net/url_request/url_request.h" #include "net/url_request/url_request_job.h" @@ -39,7 +40,7 @@ // A request job that handles reading file URLs class URLRequestFileJob : public URLRequestJob, - protected MessageLoop::Watcher { + public base::ObjectWatcher::Delegate { public: URLRequestFileJob(URLRequest* request); virtual ~URLRequestFileJob(); @@ -62,13 +63,10 @@ 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 + // base::ObjectWatcher::Delegate implementation: virtual void OnObjectSignaled(HANDLE object); // We use overlapped reads to ensure that reads from network file systems do @@ -79,6 +77,8 @@ class URLRequestFileJob : public URLRequestJob, bool is_directory_; // true when the file request is for a direcotry. bool is_not_found_; // true when the file requested does not exist. + base::ObjectWatcher watcher_; + // 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_; @@ -94,5 +94,4 @@ class URLRequestFileJob : public URLRequestJob, DISALLOW_EVIL_CONSTRUCTORS(URLRequestFileJob); }; - -#endif // BASE_URL_REQUEST_URL_REQUEST_FILE_JOB_H__ +#endif // BASE_URL_REQUEST_URL_REQUEST_FILE_JOB_H_ |