OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_URL_REQUEST_JOB_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_URL_REQUEST_JOB_H_ |
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_URL_REQUEST_JOB_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_URL_REQUEST_JOB_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 // requests for drive resources and DriveFileSytem. It exposes content URLs | 30 // requests for drive resources and DriveFileSytem. It exposes content URLs |
31 // formatted as drive:<drive-file-path>. | 31 // formatted as drive:<drive-file-path>. |
32 // The methods should be run on IO thread. | 32 // The methods should be run on IO thread. |
33 class DriveURLRequestJob : public net::URLRequestJob { | 33 class DriveURLRequestJob : public net::URLRequestJob { |
34 public: | 34 public: |
35 | 35 |
36 // Callback to return the DriveFileSystemInterface instance. This is an | 36 // Callback to return the DriveFileSystemInterface instance. This is an |
37 // injecting point for testing. | 37 // injecting point for testing. |
38 // Note that the callback will be copied between threads (IO and UI), and | 38 // Note that the callback will be copied between threads (IO and UI), and |
39 // will be called on UI thread. | 39 // will be called on UI thread. |
40 typedef base::Callback<DriveFileSystemInterface*()> DriveFileSystemGetter; | 40 typedef base::Callback<DriveFileSystemInterface*()> FileSystemGetter; |
41 | 41 |
42 DriveURLRequestJob(const DriveFileSystemGetter& file_system_getter, | 42 DriveURLRequestJob(const FileSystemGetter& file_system_getter, |
43 net::URLRequest* request, | 43 net::URLRequest* request, |
44 net::NetworkDelegate* network_delegate); | 44 net::NetworkDelegate* network_delegate); |
45 | 45 |
46 // net::URLRequestJob overrides: | 46 // net::URLRequestJob overrides: |
47 virtual void Start() OVERRIDE; | 47 virtual void Start() OVERRIDE; |
48 virtual void Kill() OVERRIDE; | 48 virtual void Kill() OVERRIDE; |
49 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; | 49 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; |
50 virtual bool IsRedirectResponse( | 50 virtual bool IsRedirectResponse( |
51 GURL* location, int* http_status_code) OVERRIDE; | 51 GURL* location, int* http_status_code) OVERRIDE; |
52 virtual bool ReadRawData( | 52 virtual bool ReadRawData( |
53 net::IOBuffer* buf, int buf_size, int* bytes_read) OVERRIDE; | 53 net::IOBuffer* buf, int buf_size, int* bytes_read) OVERRIDE; |
54 | 54 |
55 protected: | 55 protected: |
56 virtual ~DriveURLRequestJob(); | 56 virtual ~DriveURLRequestJob(); |
57 | 57 |
58 private: | 58 private: |
59 // Called when the initialization of DriveFileStreamReader is completed. | 59 // Called when the initialization of DriveFileStreamReader is completed. |
60 void OnDriveFileStreamReaderInitialized( | 60 void OnDriveFileStreamReaderInitialized( |
61 FileError error, | 61 FileError error, |
62 scoped_ptr<DriveEntryProto> entry); | 62 scoped_ptr<DriveEntryProto> entry); |
63 | 63 |
64 // Called when DriveFileStreamReader::Read is completed. | 64 // Called when DriveFileStreamReader::Read is completed. |
65 void OnReadCompleted(int read_result); | 65 void OnReadCompleted(int read_result); |
66 | 66 |
67 const DriveFileSystemGetter file_system_getter_; | 67 const FileSystemGetter file_system_getter_; |
68 | 68 |
69 scoped_ptr<DriveFileStreamReader> stream_reader_; | 69 scoped_ptr<DriveFileStreamReader> stream_reader_; |
70 scoped_ptr<DriveEntryProto> entry_; | 70 scoped_ptr<DriveEntryProto> entry_; |
71 | 71 |
72 // This should remain the last member so it'll be destroyed first and | 72 // This should remain the last member so it'll be destroyed first and |
73 // invalidate its weak pointers before other members are destroyed. | 73 // invalidate its weak pointers before other members are destroyed. |
74 base::WeakPtrFactory<DriveURLRequestJob> weak_ptr_factory_; | 74 base::WeakPtrFactory<DriveURLRequestJob> weak_ptr_factory_; |
75 DISALLOW_COPY_AND_ASSIGN(DriveURLRequestJob); | 75 DISALLOW_COPY_AND_ASSIGN(DriveURLRequestJob); |
76 }; | 76 }; |
77 | 77 |
78 } // namespace drive | 78 } // namespace drive |
79 | 79 |
80 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_URL_REQUEST_JOB_H_ | 80 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_URL_REQUEST_JOB_H_ |
OLD | NEW |