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

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

Issue 1547093002: Switch to standard integer types in chrome/browser/chromeos/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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_FILE_STREAM_READER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_STREAM_READER_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_STREAM_READER_H_ 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_STREAM_READER_H_
7 7
8 #include <stdint.h>
9
8 #include <string> 10 #include <string>
9 11
10 #include "base/basictypes.h"
11 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/scoped_vector.h" 16 #include "base/memory/scoped_vector.h"
15 #include "base/threading/thread_checker.h" 17 #include "base/threading/thread_checker.h"
16 #include "components/drive/file_errors.h" 18 #include "components/drive/file_errors.h"
17 #include "google_apis/drive/drive_api_error_codes.h" 19 #include "google_apis/drive/drive_api_error_codes.h"
18 #include "net/base/completion_callback.h" 20 #include "net/base/completion_callback.h"
19 21
20 namespace base { 22 namespace base {
21 class SequencedTaskRunner; 23 class SequencedTaskRunner;
(...skipping 29 matching lines...) Expand all
51 virtual void OnCompleted(FileError error) = 0; 53 virtual void OnCompleted(FileError error) = 0;
52 }; 54 };
53 55
54 // The read operation implementation for the locally cached files. 56 // The read operation implementation for the locally cached files.
55 class LocalReaderProxy : public ReaderProxy { 57 class LocalReaderProxy : public ReaderProxy {
56 public: 58 public:
57 // The |file_reader| should be the instance which is already opened. 59 // The |file_reader| should be the instance which is already opened.
58 // This class takes its ownership. 60 // This class takes its ownership.
59 // |length| is the number of bytes to be read. It must be equal or 61 // |length| is the number of bytes to be read. It must be equal or
60 // smaller than the remaining data size in the |file_reader|. 62 // smaller than the remaining data size in the |file_reader|.
61 LocalReaderProxy( 63 LocalReaderProxy(scoped_ptr<util::LocalFileReader> file_reader,
62 scoped_ptr<util::LocalFileReader> file_reader, int64 length); 64 int64_t length);
63 ~LocalReaderProxy() override; 65 ~LocalReaderProxy() override;
64 66
65 // ReaderProxy overrides. 67 // ReaderProxy overrides.
66 int Read(net::IOBuffer* buffer, 68 int Read(net::IOBuffer* buffer,
67 int buffer_length, 69 int buffer_length,
68 const net::CompletionCallback& callback) override; 70 const net::CompletionCallback& callback) override;
69 void OnGetContent(scoped_ptr<std::string> data) override; 71 void OnGetContent(scoped_ptr<std::string> data) override;
70 void OnCompleted(FileError error) override; 72 void OnCompleted(FileError error) override;
71 73
72 private: 74 private:
73 scoped_ptr<util::LocalFileReader> file_reader_; 75 scoped_ptr<util::LocalFileReader> file_reader_;
74 76
75 // Callback for the LocalFileReader::Read. 77 // Callback for the LocalFileReader::Read.
76 void OnReadCompleted( 78 void OnReadCompleted(
77 const net::CompletionCallback& callback, int read_result); 79 const net::CompletionCallback& callback, int read_result);
78 80
79 // The number of remaining bytes to be read. 81 // The number of remaining bytes to be read.
80 int64 remaining_length_; 82 int64_t remaining_length_;
81 83
82 base::ThreadChecker thread_checker_; 84 base::ThreadChecker thread_checker_;
83 85
84 // This should remain the last member so it'll be destroyed first and 86 // This should remain the last member so it'll be destroyed first and
85 // invalidate its weak pointers before other members are destroyed. 87 // invalidate its weak pointers before other members are destroyed.
86 base::WeakPtrFactory<LocalReaderProxy> weak_ptr_factory_; 88 base::WeakPtrFactory<LocalReaderProxy> weak_ptr_factory_;
87 DISALLOW_COPY_AND_ASSIGN(LocalReaderProxy); 89 DISALLOW_COPY_AND_ASSIGN(LocalReaderProxy);
88 }; 90 };
89 91
90 // The read operation implementation for the file which is being downloaded. 92 // The read operation implementation for the file which is being downloaded.
91 class NetworkReaderProxy : public ReaderProxy { 93 class NetworkReaderProxy : public ReaderProxy {
92 public: 94 public:
93 // If the instance is deleted during the download process, it is necessary 95 // If the instance is deleted during the download process, it is necessary
94 // to cancel the job. |job_canceller| should be the callback to run the 96 // to cancel the job. |job_canceller| should be the callback to run the
95 // cancelling. |full_content_length| is necessary for determining whether the 97 // cancelling. |full_content_length| is necessary for determining whether the
96 // deletion is done in the middle of download process. 98 // deletion is done in the middle of download process.
97 NetworkReaderProxy( 99 NetworkReaderProxy(int64_t offset,
98 int64 offset, int64 content_length, int64 full_content_length, 100 int64_t content_length,
99 const base::Closure& job_canceller); 101 int64_t full_content_length,
102 const base::Closure& job_canceller);
100 ~NetworkReaderProxy() override; 103 ~NetworkReaderProxy() override;
101 104
102 // ReaderProxy overrides. 105 // ReaderProxy overrides.
103 int Read(net::IOBuffer* buffer, 106 int Read(net::IOBuffer* buffer,
104 int buffer_length, 107 int buffer_length,
105 const net::CompletionCallback& callback) override; 108 const net::CompletionCallback& callback) override;
106 void OnGetContent(scoped_ptr<std::string> data) override; 109 void OnGetContent(scoped_ptr<std::string> data) override;
107 void OnCompleted(FileError error) override; 110 void OnCompleted(FileError error) override;
108 111
109 private: 112 private:
110 // The data received from the server, but not yet read. 113 // The data received from the server, but not yet read.
111 ScopedVector<std::string> pending_data_; 114 ScopedVector<std::string> pending_data_;
112 115
113 // The number of bytes to be skipped. 116 // The number of bytes to be skipped.
114 int64 remaining_offset_; 117 int64_t remaining_offset_;
115 118
116 // The number of bytes of remaining data (including the data not yet 119 // The number of bytes of remaining data (including the data not yet
117 // received from the server). 120 // received from the server).
118 int64 remaining_content_length_; 121 int64_t remaining_content_length_;
119 122
120 // Flag to remember whether this read request is for reading till the end of 123 // Flag to remember whether this read request is for reading till the end of
121 // the file. 124 // the file.
122 const bool is_full_download_; 125 const bool is_full_download_;
123 126
124 int error_code_; 127 int error_code_;
125 128
126 // To support pending Read(), it is necessary to keep its arguments. 129 // To support pending Read(), it is necessary to keep its arguments.
127 scoped_refptr<net::IOBuffer> buffer_; 130 scoped_refptr<net::IOBuffer> buffer_;
128 int buffer_length_; 131 int buffer_length_;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // is done. 195 // is done.
193 void InitializeAfterGetFileContentInitialized( 196 void InitializeAfterGetFileContentInitialized(
194 const net::HttpByteRange& byte_range, 197 const net::HttpByteRange& byte_range,
195 const InitializeCompletionCallback& callback, 198 const InitializeCompletionCallback& callback,
196 FileError error, 199 FileError error,
197 const base::FilePath& local_cache_file_path, 200 const base::FilePath& local_cache_file_path,
198 scoped_ptr<ResourceEntry> entry); 201 scoped_ptr<ResourceEntry> entry);
199 202
200 // Part of Initialize. Called when the local file open process is done. 203 // Part of Initialize. Called when the local file open process is done.
201 void InitializeAfterLocalFileOpen( 204 void InitializeAfterLocalFileOpen(
202 int64 length, 205 int64_t length,
203 const InitializeCompletionCallback& callback, 206 const InitializeCompletionCallback& callback,
204 scoped_ptr<ResourceEntry> entry, 207 scoped_ptr<ResourceEntry> entry,
205 scoped_ptr<util::LocalFileReader> file_reader, 208 scoped_ptr<util::LocalFileReader> file_reader,
206 int open_result); 209 int open_result);
207 210
208 // Called when the data is received from the server. 211 // Called when the data is received from the server.
209 void OnGetContent(google_apis::DriveApiErrorCode error_code, 212 void OnGetContent(google_apis::DriveApiErrorCode error_code,
210 scoped_ptr<std::string> data); 213 scoped_ptr<std::string> data);
211 214
212 // Called when GetFileContent is completed. 215 // Called when GetFileContent is completed.
(...skipping 10 matching lines...) Expand all
223 226
224 // This should remain the last member so it'll be destroyed first and 227 // This should remain the last member so it'll be destroyed first and
225 // invalidate its weak pointers before other members are destroyed. 228 // invalidate its weak pointers before other members are destroyed.
226 base::WeakPtrFactory<DriveFileStreamReader> weak_ptr_factory_; 229 base::WeakPtrFactory<DriveFileStreamReader> weak_ptr_factory_;
227 DISALLOW_COPY_AND_ASSIGN(DriveFileStreamReader); 230 DISALLOW_COPY_AND_ASSIGN(DriveFileStreamReader);
228 }; 231 };
229 232
230 } // namespace drive 233 } // namespace drive
231 234
232 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_STREAM_READER_H_ 235 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_STREAM_READER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/download_handler_unittest.cc ('k') | chrome/browser/chromeos/drive/drive_file_stream_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698