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

Unified 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 side-by-side diff with in-line comments
Download patch
« src/utils.cc ('K') | « src/utils.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/v8utils.h
===================================================================
--- src/v8utils.h (revision 6302)
+++ src/v8utils.h (working copy)
@@ -316,6 +316,39 @@
}
}
+
+// A resource for using mmapped files to back external strings that are read
+// from files.
+class MemoryMappedExternalResource: public
+ v8::String::ExternalAsciiStringResource {
+ public:
+ explicit MemoryMappedExternalResource(const char* filename);
+ explicit MemoryMappedExternalResource(const char* filename,
mnaganov (inactive) 2011/01/16 10:16:02 2-args constructor does not need to be explicit.
marklam 2011/01/18 02:49:02 Done.
+ bool remove_file_on_cleanup);
+ virtual ~MemoryMappedExternalResource();
+
+ virtual const char* data() const { return data_; }
+ virtual size_t length() const { return length_; }
+
+ bool Exists() const { return file_ != NULL; }
mnaganov (inactive) 2011/01/16 10:16:02 Simple getter-like functions should be named lower
marklam 2011/01/18 02:49:02 Done.
+ bool IsEmpty() const { return length_ == 0; }
+
+ bool EnsureIsAscii(bool abort_if_failed = true) const;
+ bool EnsureIsAscii() const { return EnsureIsAscii(true); }
mnaganov (inactive) 2011/01/16 10:16:02 Not sure that both versions of EnsureIsAscii shoul
marklam 2011/01/18 02:49:02 Done. This was partially revised code to remove t
+ bool IsAscii() const { return EnsureIsAscii(false); }
+
+ private:
+ void Init(const char* filename);
+
+ char* filename_;
+ OS::MemoryMappedFile* file_;
+
+ const char* data_;
+ size_t length_;
+ bool remove_file_on_cleanup_;
+};
+
+
} } // namespace v8::internal
#endif // V8_V8UTILS_H_
« 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