Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: chrome/browser/chromeos/drive/drive_url_request_job.h

Issue 560313002: Use ExternalFileSystemBackend in the DriveURLRequestJob. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
15 #include "chrome/browser/chromeos/drive/file_errors.h" 13 #include "chrome/browser/chromeos/drive/file_errors.h"
16 #include "net/http/http_byte_range.h" 14 #include "net/http/http_byte_range.h"
17 #include "net/url_request/url_request_job.h" 15 #include "net/url_request/url_request_job.h"
18 16 #include "storage/browser/blob/file_stream_reader.h"
19 namespace base { 17 #include "storage/browser/fileapi/file_system_url.h"
20 class SequencedTaskRunner;
21 } // namespace
22 18
23 namespace net { 19 namespace net {
24 class IOBuffer; 20 class IOBuffer;
25 class NetworkDelegate; 21 class NetworkDelegate;
26 class URLRequest; 22 class URLRequest;
27 } // namespace net 23 } // namespace net
28 24
29 namespace drive { 25 namespace drive {
30 26
31 class DriveFileStreamReader;
32 class FileSystemInterface;
33 class ResourceEntry;
34
35 // DriveURLRequestJob is the gateway between network-level drive:... 27 // DriveURLRequestJob is the gateway between network-level drive:...
36 // requests for drive resources and FileSystem. It exposes content URLs 28 // requests for drive resources and FileSystem. It exposes content URLs
37 // formatted as drive:<drive-file-path>. 29 // formatted as drive:<drive-file-path>.
38 // The methods should be run on IO thread, and the operations to communicate 30 // The methods should be run on IO thread.
39 // with a locally cached file will run on |file_task_runner|.
40 class DriveURLRequestJob : public net::URLRequestJob { 31 class DriveURLRequestJob : public net::URLRequestJob {
41 public: 32 public:
42 33 DriveURLRequestJob(void* profile_id,
43 // Callback to return the FileSystemInterface instance. This is an
44 // injecting point for testing.
45 // Note that the callback will be copied between threads (IO and UI), and
46 // will be called on UI thread.
47 typedef base::Callback<FileSystemInterface*()> FileSystemGetter;
48
49 DriveURLRequestJob(const FileSystemGetter& file_system_getter,
50 base::SequencedTaskRunner* file_task_runner,
51 net::URLRequest* request, 34 net::URLRequest* request,
52 net::NetworkDelegate* network_delegate); 35 net::NetworkDelegate* network_delegate);
53 36
54 // net::URLRequestJob overrides: 37 // net::URLRequestJob overrides:
55 virtual void SetExtraRequestHeaders(const net::HttpRequestHeaders& headers) 38 virtual void SetExtraRequestHeaders(const net::HttpRequestHeaders& headers)
56 OVERRIDE; 39 OVERRIDE;
57 virtual void Start() OVERRIDE; 40 virtual void Start() OVERRIDE;
58 virtual void Kill() OVERRIDE; 41 virtual void Kill() OVERRIDE;
59 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; 42 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE;
60 virtual bool IsRedirectResponse( 43 virtual bool IsRedirectResponse(
61 GURL* location, int* http_status_code) OVERRIDE; 44 GURL* location, int* http_status_code) OVERRIDE;
62 virtual bool ReadRawData( 45 virtual bool ReadRawData(
63 net::IOBuffer* buf, int buf_size, int* bytes_read) OVERRIDE; 46 net::IOBuffer* buf, int buf_size, int* bytes_read) OVERRIDE;
64 47
65 protected: 48 protected:
66 virtual ~DriveURLRequestJob(); 49 virtual ~DriveURLRequestJob();
67 50
68 private: 51 private:
69 // Called when the initialization of DriveFileStreamReader is completed. 52 class GetFileSystemContextDelegate;
70 void OnDriveFileStreamReaderInitialized( 53 typedef base::Callback<void(scoped_ptr<GetFileSystemContextDelegate>)>
71 int error, scoped_ptr<ResourceEntry> entry); 54 DelegateCallback;
55
56 // Called after Start method.
mtomasz 2014/09/18 07:21:07 OnGotDelegate -> OnDelegateObtained to be consiste
hirono 2014/09/18 08:18:55 Done.
57 void OnGotDelegate(scoped_ptr<GetFileSystemContextDelegate> delegate);
58
59 // Called after OnGotDelegate method.
mtomasz 2014/09/18 07:21:07 I think this comment is not very helpful. We shoul
hirono 2014/09/18 08:18:55 Done.
60 void OnRedirectURLObtained(const GURL& redirect_url);
61
62 // Called after OnRedirectURLObtained method.
63 void OnFileInfoObtained(base::File::Error result,
64 const base::File::Info& file_info);
65
66 // Called after OnFileInfoObtained method.
67 void OnMimeTypeObtained(const std::string& mime_type);
72 68
73 // Called when DriveFileStreamReader::Read is completed. 69 // Called when DriveFileStreamReader::Read is completed.
74 void OnReadCompleted(int read_result); 70 void OnReadCompleted(int read_result);
75 71
76 const FileSystemGetter file_system_getter_; 72 void* const profile_id_;
77 scoped_refptr<base::SequencedTaskRunner> file_task_runner_;
78 73
79 // The range of the file to be returned. 74 // The range of the file to be returned.
80 net::HttpByteRange byte_range_; 75 net::HttpByteRange byte_range_;
76 int total_bytes_read_;
81 77
82 scoped_ptr<DriveFileStreamReader> stream_reader_; 78 scoped_ptr<GetFileSystemContextDelegate> delegate_;
83 scoped_ptr<ResourceEntry> entry_; 79 scoped_ptr<storage::FileStreamReader> stream_reader_;
80 GURL redirect_url_;
84 81
85 // This should remain the last member so it'll be destroyed first and 82 // This should remain the last member so it'll be destroyed first and
86 // invalidate its weak pointers before other members are destroyed. 83 // invalidate its weak pointers before other members are destroyed.
87 base::WeakPtrFactory<DriveURLRequestJob> weak_ptr_factory_; 84 base::WeakPtrFactory<DriveURLRequestJob> weak_ptr_factory_;
88 DISALLOW_COPY_AND_ASSIGN(DriveURLRequestJob); 85 DISALLOW_COPY_AND_ASSIGN(DriveURLRequestJob);
89 }; 86 };
90 87
91 } // namespace drive 88 } // namespace drive
92 89
93 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_URL_REQUEST_JOB_H_ 90 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_URL_REQUEST_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698