OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_DRIVE_DRIVE_API_UTIL_H_ | 5 #ifndef CHROME_BROWSER_DRIVE_DRIVE_API_UTIL_H_ |
6 #define CHROME_BROWSER_DRIVE_DRIVE_API_UTIL_H_ | 6 #define CHROME_BROWSER_DRIVE_DRIVE_API_UTIL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/md5.h" | 10 #include "base/md5.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 // Computes an MD5 digest of data read from the given |streamReader|. The | 85 // Computes an MD5 digest of data read from the given |streamReader|. The |
86 // work occurs asynchronously, and the resulting hash is returned via the | 86 // work occurs asynchronously, and the resulting hash is returned via the |
87 // |callback|. If an error occurs, |callback| is called with an empty string. | 87 // |callback|. If an error occurs, |callback| is called with an empty string. |
88 // Only one stream can be processed at a time by each digester. Do not call | 88 // Only one stream can be processed at a time by each digester. Do not call |
89 // GetMd5Digest before the results of a previous call have been returned. | 89 // GetMd5Digest before the results of a previous call have been returned. |
90 void GetMd5Digest(scoped_ptr<storage::FileStreamReader> stream_reader, | 90 void GetMd5Digest(scoped_ptr<storage::FileStreamReader> stream_reader, |
91 const ResultCallback& callback); | 91 const ResultCallback& callback); |
92 | 92 |
93 private: | 93 private: |
94 // Kicks off a read of the next chunk from the stream. | 94 // Kicks off a read of the next chunk from the stream. |
95 void ReadNextChunk(); | 95 void ReadNextChunk(const ResultCallback& callback); |
96 // Handles the incoming chunk of data from a stream read. | 96 // Handles the incoming chunk of data from a stream read. |
97 void OnChunkRead(int result); | 97 void OnChunkRead(const ResultCallback& callback, int bytes_read); |
98 | 98 |
99 // Maximum chunk size for read operations. | 99 // Maximum chunk size for read operations. |
100 scoped_ptr<storage::FileStreamReader> reader_; | 100 scoped_ptr<storage::FileStreamReader> reader_; |
101 ResultCallback callback_; | |
102 scoped_refptr<net::IOBuffer> buffer_; | 101 scoped_refptr<net::IOBuffer> buffer_; |
103 base::MD5Context md5_context_; | 102 base::MD5Context md5_context_; |
104 | 103 |
105 DISALLOW_COPY_AND_ASSIGN(FileStreamMd5Digester); | 104 DISALLOW_COPY_AND_ASSIGN(FileStreamMd5Digester); |
106 }; | 105 }; |
107 | 106 |
108 // Returns preferred file extension for hosted documents which have given mime | 107 // Returns preferred file extension for hosted documents which have given mime |
109 // type. | 108 // type. |
110 std::string GetHostedDocumentExtension(const std::string& mime_type); | 109 std::string GetHostedDocumentExtension(const std::string& mime_type); |
111 | 110 |
112 // Returns true if the given mime type is corresponding to one of known hosted | 111 // Returns true if the given mime type is corresponding to one of known hosted |
113 // document types. | 112 // document types. |
114 bool IsKnownHostedDocumentMimeType(const std::string& mime_type); | 113 bool IsKnownHostedDocumentMimeType(const std::string& mime_type); |
115 | 114 |
116 // Returns true if the given file path has an extension corresponding to one of | 115 // Returns true if the given file path has an extension corresponding to one of |
117 // hosted document types. | 116 // hosted document types. |
118 bool HasHostedDocumentExtension(const base::FilePath& path); | 117 bool HasHostedDocumentExtension(const base::FilePath& path); |
119 | 118 |
120 } // namespace util | 119 } // namespace util |
121 } // namespace drive | 120 } // namespace drive |
122 | 121 |
123 #endif // CHROME_BROWSER_DRIVE_DRIVE_API_UTIL_H_ | 122 #endif // CHROME_BROWSER_DRIVE_DRIVE_API_UTIL_H_ |
OLD | NEW |