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

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

Issue 580023003: Rename the drive: scheme with the externalfile: scheme. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_URL_REQUEST_JOB_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_URL_REQUEST_JOB_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "base/memory/weak_ptr.h"
13 #include "chrome/browser/chromeos/drive/file_errors.h"
14 #include "net/base/net_errors.h"
15 #include "net/http/http_byte_range.h"
16 #include "net/url_request/url_request_job.h"
17 #include "storage/browser/blob/file_stream_reader.h"
18 #include "storage/browser/fileapi/file_system_url.h"
19
20 namespace net {
21 class IOBuffer;
22 class NetworkDelegate;
23 class URLRequest;
24 } // namespace net
25
26 namespace drive {
27
28 // DriveURLRequestJob is the gateway between network-level drive:...
29 // requests for drive resources and FileSystem. It exposes content URLs
30 // formatted as drive:<drive-file-path>.
31 // The methods should be run on IO thread.
32 class DriveURLRequestJob : public net::URLRequestJob {
33 public:
34 typedef base::Callback<void(
35 net::Error,
36 const scoped_refptr<storage::FileSystemContext>& file_system_context,
37 const storage::FileSystemURL& file_system_url,
38 const std::string& mime_type)> DelegateCallback;
39
40 DriveURLRequestJob(void* profile_id,
41 net::URLRequest* request,
42 net::NetworkDelegate* network_delegate);
43
44 // net::URLRequestJob overrides:
45 virtual void SetExtraRequestHeaders(const net::HttpRequestHeaders& headers)
46 OVERRIDE;
47 virtual void Start() OVERRIDE;
48 virtual void Kill() OVERRIDE;
49 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE;
50 virtual bool IsRedirectResponse(
51 GURL* location, int* http_status_code) OVERRIDE;
52 virtual bool ReadRawData(
53 net::IOBuffer* buf, int buf_size, int* bytes_read) OVERRIDE;
54
55 protected:
56 virtual ~DriveURLRequestJob();
57
58 private:
59 // Called from a delegete helper on the UI thread.
60 void OnDelegateResultObtained(
61 net::Error error,
62 const scoped_refptr<storage::FileSystemContext>& file_system_context,
63 const storage::FileSystemURL& file_system_url,
64 const std::string& mime_type);
65
66 // Called from FileSystemBackend::GetRedirectURLForContents.
67 void OnRedirectURLObtained(const GURL& redirect_url);
68
69 // Called from DriveURLRequestJob::OnFileInfoObtained.
70 void OnFileInfoObtained(base::File::Error result,
71 const base::File::Info& file_info);
72
73 // Called when DriveFileStreamReader::Read is completed.
74 void OnReadCompleted(int read_result);
75
76 void* const profile_id_;
77
78 // The range of the file to be returned.
79 net::HttpByteRange byte_range_;
80 int64 remaining_bytes_;
81
82 scoped_refptr<storage::FileSystemContext> file_system_context_;
83 storage::FileSystemURL file_system_url_;
84 std::string mime_type_;
85 scoped_ptr<storage::FileStreamReader> stream_reader_;
86 GURL redirect_url_;
87
88 // This should remain the last member so it'll be destroyed first and
89 // invalidate its weak pointers before other members are destroyed.
90 base::WeakPtrFactory<DriveURLRequestJob> weak_ptr_factory_;
91 DISALLOW_COPY_AND_ASSIGN(DriveURLRequestJob);
92 };
93
94 } // namespace drive
95
96 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_URL_REQUEST_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698