summaryrefslogtreecommitdiffstats
path: root/chrome/browser/bookmarks
diff options
context:
space:
mode:
authorpaivanof@gmail.com <paivanof@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-06 00:29:51 +0000
committerpaivanof@gmail.com <paivanof@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-06 00:29:51 +0000
commitaab1b9ead19f21af4f752c4a52beed65009d96fb (patch)
tree3679bc3c3bd80678a9fb2ab383aa6834679506d0 /chrome/browser/bookmarks
parent25524c044d4aefd6902d4245b66980c46669e145 (diff)
downloadchromium_src-aab1b9ead19f21af4f752c4a52beed65009d96fb.zip
chromium_src-aab1b9ead19f21af4f752c4a52beed65009d96fb.tar.gz
chromium_src-aab1b9ead19f21af4f752c4a52beed65009d96fb.tar.bz2
net: Implement canceling of all async operations in FileStream.
Canceling of async operations allows to not wait for their completion in FileStream's destructor. Other related changes include: - Got rid of FileStream::Close() and FileStream::CloseSync() methods because reuse of FileStream object doesn't make much sense, it should be destroyed instead. - Changed FileStream to always acquire ownership of the PlatformFile it was given. Fixed usages of FileStream where no ownership was assumed, introduced new helper functions in base/platform_file.h on the way. - FileStream's destructor now always closes the file. If file was opened with PLATFORM_FILE_ASYNC then actual closing is done asynchronously, destructor doesn't wait for that and returns immediately. When file was opened without PLATFORM_FILE_ASYNC closing is done synchronously and the thread doing that should be allowed to do IO operations. - Implementation of FileStream is refactored. FileStream is now just a wrapper around internal object that does all actual work and that can be easily orphaned in the destructor to not block on the actual file descriptor closing. All platform-independent code is extracted into a special file and amount of platform-dependent code is minimized. BUG=115067, 112474 TEST=net_unittests Review URL: https://chromiumcodereview.appspot.com/10701050 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166091 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/bookmarks')
-rw-r--r--chrome/browser/bookmarks/bookmark_html_writer.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/chrome/browser/bookmarks/bookmark_html_writer.cc b/chrome/browser/bookmarks/bookmark_html_writer.cc
index fef222f..4cc20ec 100644
--- a/chrome/browser/bookmarks/bookmark_html_writer.cc
+++ b/chrome/browser/bookmarks/bookmark_html_writer.cc
@@ -97,8 +97,7 @@ class Writer : public base::RefCountedThreadSafe<Writer> {
: bookmarks_(bookmarks),
path_(path),
favicons_map_(favicons_map),
- observer_(observer),
- file_stream_(NULL) {
+ observer_(observer) {
}
// Writing bookmarks and favicons data to file.
@@ -149,7 +148,7 @@ class Writer : public base::RefCountedThreadSafe<Writer> {
Write(kFolderChildrenEnd);
Write(kNewline);
// File stream close is forced so that unit test could read it.
- file_stream_.CloseSync();
+ file_stream_.reset();
NotifyOnFinish();
}
@@ -172,8 +171,9 @@ class Writer : public base::RefCountedThreadSafe<Writer> {
// Opens the file, returning true on success.
bool OpenFile() {
+ file_stream_.reset(new net::FileStream(NULL));
int flags = base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_WRITE;
- return (file_stream_.OpenSync(path_, flags) == net::OK);
+ return (file_stream_->OpenSync(path_, flags) == net::OK);
}
// Increments the indent.
@@ -197,7 +197,7 @@ class Writer : public base::RefCountedThreadSafe<Writer> {
// Writes raw text out returning true on success. This does not escape
// the text in anyway.
bool Write(const std::string& text) {
- size_t wrote = file_stream_.WriteSync(text.c_str(), text.length());
+ size_t wrote = file_stream_->WriteSync(text.c_str(), text.length());
bool result = (wrote == text.length());
DCHECK(result);
return result;
@@ -374,7 +374,7 @@ class Writer : public base::RefCountedThreadSafe<Writer> {
BookmarksExportObserver* observer_;
// File we're writing to.
- net::FileStream file_stream_;
+ scoped_ptr<net::FileStream> file_stream_;
// How much we indent when writing a bookmark/folder. This is modified
// via IncrementIndent and DecrementIndent.