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

Unified Diff: chrome/browser/bookmarks/bookmark_html_writer.cc

Issue 10701050: net: Implement canceling of all async operations in FileStream. (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Update after http://crrev.com/159454 Created 8 years, 3 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
Index: chrome/browser/bookmarks/bookmark_html_writer.cc
diff --git a/chrome/browser/bookmarks/bookmark_html_writer.cc b/chrome/browser/bookmarks/bookmark_html_writer.cc
index 6e2412d24964e5b50e0aa077aaf1b24171783888..a14e3d4159383ca2b7cec43c8a1d1986102bd6a1 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.

Powered by Google App Engine
This is Rietveld 408576698