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

Side by Side Diff: native_client_sdk/src/libraries/nacl_io/mount_node_http.cc

Issue 18644009: [NaCl SDK] Upate atomic ops in nacl_io (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add declartions for newval and oldval Created 7 years, 5 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
OLDNEW
1 /* Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 /* Copyright (c) 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 5
6 #include "nacl_io/mount_node_http.h" 6 #include "nacl_io/mount_node_http.h"
7 7
8 #include <assert.h> 8 #include <assert.h>
9 #include <errno.h> 9 #include <errno.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 153
154 Error MountNodeHttp::GetDents(size_t offs, 154 Error MountNodeHttp::GetDents(size_t offs,
155 struct dirent* pdir, 155 struct dirent* pdir,
156 size_t count, 156 size_t count,
157 int* out_bytes) { 157 int* out_bytes) {
158 *out_bytes = 0; 158 *out_bytes = 0;
159 return ENOSYS; 159 return ENOSYS;
160 } 160 }
161 161
162 Error MountNodeHttp::GetStat(struct stat* stat) { 162 Error MountNodeHttp::GetStat(struct stat* stat) {
163 AutoLock lock(&lock_); 163 AUTO_LOCK(node_lock_);
164 164
165 // Assume we need to 'HEAD' if we do not know the size, otherwise, assume 165 // Assume we need to 'HEAD' if we do not know the size, otherwise, assume
166 // that the information is constant. We can add a timeout if needed. 166 // that the information is constant. We can add a timeout if needed.
167 MountHttp* mount = static_cast<MountHttp*>(mount_); 167 MountHttp* mount = static_cast<MountHttp*>(mount_);
168 if (stat_.st_size == 0 || !mount->cache_stat_) { 168 if (stat_.st_size == 0 || !mount->cache_stat_) {
169 StringMap_t headers; 169 StringMap_t headers;
170 PP_Resource loader; 170 PP_Resource loader;
171 PP_Resource request; 171 PP_Resource request;
172 PP_Resource response; 172 PP_Resource response;
173 int32_t statuscode; 173 int32_t statuscode;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 211
212 return 0; 212 return 0;
213 } 213 }
214 214
215 Error MountNodeHttp::Read(size_t offs, 215 Error MountNodeHttp::Read(size_t offs,
216 void* buf, 216 void* buf,
217 size_t count, 217 size_t count,
218 int* out_bytes) { 218 int* out_bytes) {
219 *out_bytes = 0; 219 *out_bytes = 0;
220 220
221 AutoLock lock(&lock_); 221 AUTO_LOCK(node_lock_);
222 if (cache_content_) { 222 if (cache_content_) {
223 if (cached_data_.empty()) { 223 if (cached_data_.empty()) {
224 Error error = DownloadToCache(); 224 Error error = DownloadToCache();
225 if (error) 225 if (error)
226 return error; 226 return error;
227 } 227 }
228 228
229 return ReadPartialFromCache(offs, buf, count, out_bytes); 229 return ReadPartialFromCache(offs, buf, count, out_bytes);
230 } 230 }
231 231
232 return DownloadPartial(offs, buf, count, out_bytes); 232 return DownloadPartial(offs, buf, count, out_bytes);
233 } 233 }
234 234
235 Error MountNodeHttp::FTruncate(off_t size) { return ENOSYS; } 235 Error MountNodeHttp::FTruncate(off_t size) { return ENOSYS; }
236 236
237 Error MountNodeHttp::Write(size_t offs, 237 Error MountNodeHttp::Write(size_t offs,
238 const void* buf, 238 const void* buf,
239 size_t count, 239 size_t count,
240 int* out_bytes) { 240 int* out_bytes) {
241 // TODO(binji): support POST? 241 // TODO(binji): support POST?
242 *out_bytes = 0; 242 *out_bytes = 0;
243 return ENOSYS; 243 return ENOSYS;
244 } 244 }
245 245
246 Error MountNodeHttp::GetSize(size_t* out_size) { 246 Error MountNodeHttp::GetSize(size_t* out_size) {
247 *out_size = 0; 247 *out_size = 0;
248 248
249 // TODO(binji): This value should be cached properly; i.e. obey the caching 249 // TODO(binji): This value should be cached properly; i.e. obey the caching
250 // headers returned by the server. 250 // headers returned by the server.
251 AutoLock lock(&lock_); 251 AUTO_LOCK(node_lock_);
252 if (!has_cached_size_) { 252 if (!has_cached_size_) {
253 // Even if DownloadToCache fails, the best result we can return is what 253 // Even if DownloadToCache fails, the best result we can return is what
254 // was written to stat_.st_size. 254 // was written to stat_.st_size.
255 if (cache_content_) { 255 if (cache_content_) {
256 Error error = DownloadToCache(); 256 Error error = DownloadToCache();
257 if (error) 257 if (error)
258 return error; 258 return error;
259 } 259 }
260 } 260 }
261 261
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 532
533 assert(bytes_read <= bytes_to_read); 533 assert(bytes_read <= bytes_to_read);
534 bytes_to_read -= bytes_read; 534 bytes_to_read -= bytes_read;
535 out_buffer += bytes_read; 535 out_buffer += bytes_read;
536 } 536 }
537 537
538 *out_bytes = count; 538 *out_bytes = count;
539 return 0; 539 return 0;
540 } 540 }
541 541
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698