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

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

Issue 13065007: Fix data overwriting issue on ReadFromDownloadData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments. Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/drive_url_request_job.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/scoped_vector.h"
14 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
15 #include "base/string_piece.h" 16 #include "base/string_piece.h"
16 #include "chrome/browser/chromeos/drive/drive_file_error.h" 17 #include "chrome/browser/chromeos/drive/drive_file_error.h"
17 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h" 18 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h"
18 #include "chrome/browser/google_apis/gdata_errorcode.h" 19 #include "chrome/browser/google_apis/gdata_errorcode.h"
19 #include "net/url_request/url_request_job.h" 20 #include "net/url_request/url_request_job.h"
20 21
21 namespace net { 22 namespace net {
22 class FileStream; 23 class FileStream;
23 class HttpResponseInfo; 24 class HttpResponseInfo;
24 class IOBuffer; 25 class IOBuffer;
25 class NetworkDelegate; 26 class NetworkDelegate;
26 class URLRequest; 27 class URLRequest;
27 } // namespace net 28 } // namespace net
28 29
29 namespace drive { 30 namespace drive {
30 31
31 class DriveEntryProto; 32 class DriveEntryProto;
32 class DriveFileSystemInterface; 33 class DriveFileSystemInterface;
33 34
34 // DriveURLRequesetJob is the gateway between network-level drive://... 35 // DriveURLRequesetJob is the gateway between network-level drive://...
35 // requests for drive resources and DriveFileSytem. It exposes content URLs 36 // requests for drive resources and DriveFileSytem. It exposes content URLs
36 // formatted as drive://<resource-id>. 37 // formatted as drive://<resource-id>.
37 // The methods should be run on IO thread. 38 // The methods should be run on IO thread.
39 // This class seems to have some timing issue and to handle edge cases somehow
40 // wrongly. Also, probably because of the requirement change, the code path
41 // is getting complicated.
42 // TODO(hidehiko): Clean the code up and handles edge cases correctly.
38 class DriveURLRequestJob : public net::URLRequestJob { 43 class DriveURLRequestJob : public net::URLRequestJob {
39 public: 44 public:
40 45
41 // Callback to return the DriveFileSystemInterface instance. This is an 46 // Callback to return the DriveFileSystemInterface instance. This is an
42 // injecting point for testing. 47 // injecting point for testing.
43 // Note that the callback will be copied between threads (IO and UI), and 48 // Note that the callback will be copied between threads (IO and UI), and
44 // will be called on UI thread. 49 // will be called on UI thread.
45 typedef base::Callback<DriveFileSystemInterface*()> DriveFileSystemGetter; 50 typedef base::Callback<DriveFileSystemInterface*()> DriveFileSystemGetter;
46 51
47 DriveURLRequestJob( 52 DriveURLRequestJob(
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 base::FilePath local_file_path_; 129 base::FilePath local_file_path_;
125 base::FilePath drive_file_path_; 130 base::FilePath drive_file_path_;
126 std::string mime_type_; 131 std::string mime_type_;
127 int64 initial_file_size_; 132 int64 initial_file_size_;
128 int64 remaining_bytes_; 133 int64 remaining_bytes_;
129 scoped_ptr<net::FileStream> stream_; 134 scoped_ptr<net::FileStream> stream_;
130 scoped_ptr<net::HttpResponseInfo> response_info_; 135 scoped_ptr<net::HttpResponseInfo> response_info_;
131 bool streaming_download_; 136 bool streaming_download_;
132 scoped_refptr<net::IOBuffer> read_buf_; 137 scoped_refptr<net::IOBuffer> read_buf_;
133 base::StringPiece read_buf_remaining_; 138 base::StringPiece read_buf_remaining_;
134 std::string download_buf_; 139 ScopedVector<std::string> pending_downloaded_data_;
135 base::StringPiece download_buf_remaining_;
136 140
137 // This should remain the last member so it'll be destroyed first and 141 // This should remain the last member so it'll be destroyed first and
138 // invalidate its weak pointers before other members are destroyed. 142 // invalidate its weak pointers before other members are destroyed.
139 base::WeakPtrFactory<DriveURLRequestJob> weak_ptr_factory_; 143 base::WeakPtrFactory<DriveURLRequestJob> weak_ptr_factory_;
140 DISALLOW_COPY_AND_ASSIGN(DriveURLRequestJob); 144 DISALLOW_COPY_AND_ASSIGN(DriveURLRequestJob);
141 }; 145 };
142 146
143 } // namespace drive 147 } // namespace drive
144 148
145 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_URL_REQUEST_JOB_H_ 149 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_URL_REQUEST_JOB_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/drive_url_request_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698