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

Side by Side Diff: src/v8utils.h

Issue 6240002: Introducing MemoryMappedExternalResource for creating an external... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 11 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
« src/utils.cc ('K') | « src/utils.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 dest += kStepSize; 309 dest += kStepSize;
310 src += kStepSize; 310 src += kStepSize;
311 } 311 }
312 } 312 }
313 #endif 313 #endif
314 while (dest < limit) { 314 while (dest < limit) {
315 *dest++ = static_cast<sinkchar>(*src++); 315 *dest++ = static_cast<sinkchar>(*src++);
316 } 316 }
317 } 317 }
318 318
319
320 // A resource for using mmapped files to back external strings that are read
321 // from files.
322 class MemoryMappedExternalResource: public
323 v8::String::ExternalAsciiStringResource {
324 public:
325 explicit MemoryMappedExternalResource(const char* filename);
326 MemoryMappedExternalResource(const char* filename,
327 bool remove_file_on_cleanup);
328 virtual ~MemoryMappedExternalResource();
329
330 virtual const char* data() const { return data_; }
331 virtual size_t length() const { return length_; }
332
333 bool exists() const { return file_ != NULL; }
334 bool IsEmpty() const { return length_ == 0; }
mnaganov (inactive) 2011/01/18 10:13:34 is_empty() -- this is a getter-like operation.
marklam 2011/01/18 17:32:47 Done.
335
336 bool EnsureIsAscii(bool abort_if_failed) const;
337 bool EnsureIsAscii() const { return EnsureIsAscii(true); }
338 bool IsAscii() const { return EnsureIsAscii(false); }
339
340 private:
341 void Init(const char* filename);
342
343 char* filename_;
344 OS::MemoryMappedFile* file_;
345
346 const char* data_;
347 size_t length_;
348 bool remove_file_on_cleanup_;
349 };
350
351
319 } } // namespace v8::internal 352 } } // namespace v8::internal
320 353
321 #endif // V8_V8UTILS_H_ 354 #endif // V8_V8UTILS_H_
OLDNEW
« src/utils.cc ('K') | « src/utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698