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

Unified Diff: chrome/browser/visitedlink/visitedlink_master.h

Issue 10800005: Do not open file on UI thread in VisitedLinkMaster (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/visitedlink/visitedlink_master.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/visitedlink/visitedlink_master.h
===================================================================
--- chrome/browser/visitedlink/visitedlink_master.h (revision 148849)
+++ chrome/browser/visitedlink/visitedlink_master.h (working copy)
@@ -116,8 +116,8 @@
// Call to cause the entire database file to be re-written from scratch
// to disk. Used by the performance tester.
- bool RewriteFile() {
- return WriteFullTable();
+ void RewriteFile() {
+ WriteFullTable();
}
#endif
@@ -168,9 +168,9 @@
void PostIOTask(const tracked_objects::Location& from_here,
const base::Closure& task);
- // Writes the entire table to disk, returning true on success. It will leave
- // the table file open and the handle to it in file_
- bool WriteFullTable();
+ // Writes the entire table to disk. It will leave the table file open and
+ // the handle to it will be stored in file_.
+ void WriteFullTable();
// Try to load the table from the database file. If the file doesn't exist or
// is corrupt, this will return failure.
@@ -191,7 +191,7 @@
// Wrapper around Window's WriteFile using asynchronous I/O. This will proxy
// the write to a background thread.
- void WriteToFile(FILE* hfile, off_t offset, void* data, int32 data_size);
+ void WriteToFile(FILE** hfile, off_t offset, void* data, int32 data_size);
// Helper function to schedule and asynchronous write of the used count to
// disk (this is a common operation).
@@ -337,8 +337,14 @@
// The currently open file with the table in it. This may be NULL if we're
// rebuilding and haven't written a new version yet. Writing to the file may
- // be safely ignored in this case.
- FILE* file_;
+ // be safely ignored in this case. Also |file_| may be non-NULL but point to
+ // a NULL pointer. That would mean that opening of the file is already
+ // scheduled in a background thread and any writing to the file can also be
+ // scheduled to the background thread as it's guaranteed to be executed after
+ // the opening.
+ // The class owns both the |file_| pointer and the pointer pointed
+ // by |*file_|.
+ FILE** file_;
// Shared memory consists of a SharedHeader followed by the table.
base::SharedMemory *shared_memory_;
« no previous file with comments | « no previous file | chrome/browser/visitedlink/visitedlink_master.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698