OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/bookmarks/bookmark_html_writer.h" | 5 #include "chrome/browser/bookmarks/bookmark_html_writer.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 !WriteNode(*static_cast<DictionaryValue*>(mobile_folder_value), | 138 !WriteNode(*static_cast<DictionaryValue*>(mobile_folder_value), |
139 BookmarkNode::MOBILE)) { | 139 BookmarkNode::MOBILE)) { |
140 return; | 140 return; |
141 } | 141 } |
142 | 142 |
143 DecrementIndent(); | 143 DecrementIndent(); |
144 | 144 |
145 Write(kFolderChildrenEnd); | 145 Write(kFolderChildrenEnd); |
146 Write(kNewline); | 146 Write(kNewline); |
147 // File stream close is forced so that unit test could read it. | 147 // File stream close is forced so that unit test could read it. |
148 file_stream_.Close(); | 148 file_stream_.CloseSync(); |
149 | 149 |
150 NotifyOnFinish(); | 150 NotifyOnFinish(); |
151 } | 151 } |
152 | 152 |
153 private: | 153 private: |
154 // Types of text being written out. The type dictates how the text is | 154 // Types of text being written out. The type dictates how the text is |
155 // escaped. | 155 // escaped. |
156 enum TextType { | 156 enum TextType { |
157 // The text is the value of an html attribute, eg foo in | 157 // The text is the value of an html attribute, eg foo in |
158 // <a href="foo">. | 158 // <a href="foo">. |
159 ATTRIBUTE_VALUE, | 159 ATTRIBUTE_VALUE, |
160 | 160 |
161 // Actual content, eg foo in <h1>foo</h2>. | 161 // Actual content, eg foo in <h1>foo</h2>. |
162 CONTENT | 162 CONTENT |
163 }; | 163 }; |
164 | 164 |
165 // Opens the file, returning true on success. | 165 // Opens the file, returning true on success. |
166 bool OpenFile() { | 166 bool OpenFile() { |
167 int flags = base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_WRITE; | 167 int flags = base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_WRITE; |
168 return (file_stream_.Open(path_, flags) == net::OK); | 168 return (file_stream_.OpenSync(path_, flags) == net::OK); |
169 } | 169 } |
170 | 170 |
171 // Increments the indent. | 171 // Increments the indent. |
172 void IncrementIndent() { | 172 void IncrementIndent() { |
173 indent_.resize(indent_.size() + kIndentSize, ' '); | 173 indent_.resize(indent_.size() + kIndentSize, ' '); |
174 } | 174 } |
175 | 175 |
176 // Decrements the indent. | 176 // Decrements the indent. |
177 void DecrementIndent() { | 177 void DecrementIndent() { |
178 DCHECK(!indent_.empty()); | 178 DCHECK(!indent_.empty()); |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 // BookmarkModel isn't thread safe (nor would we want to lock it down | 490 // BookmarkModel isn't thread safe (nor would we want to lock it down |
491 // for the duration of the write), as such we make a copy of the | 491 // for the duration of the write), as such we make a copy of the |
492 // BookmarkModel using BookmarkCodec then write from that. | 492 // BookmarkModel using BookmarkCodec then write from that. |
493 if (fetcher == NULL) { | 493 if (fetcher == NULL) { |
494 fetcher = new BookmarkFaviconFetcher(profile, path, observer); | 494 fetcher = new BookmarkFaviconFetcher(profile, path, observer); |
495 fetcher->ExportBookmarks(); | 495 fetcher->ExportBookmarks(); |
496 } | 496 } |
497 } | 497 } |
498 | 498 |
499 } // namespace bookmark_html_writer | 499 } // namespace bookmark_html_writer |
OLD | NEW |