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

Side by Side Diff: chrome/browser/bookmarks/bookmark_html_writer.cc

Issue 18764: Change FileStream to use FilePath instead of wstring. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/common/unzip.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/file_path.h"
7 #include "base/file_util.h" 8 #include "base/file_util.h"
8 #include "base/message_loop.h" 9 #include "base/message_loop.h"
9 #include "base/platform_file.h" 10 #include "base/platform_file.h"
10 #include "base/scoped_ptr.h" 11 #include "base/scoped_ptr.h"
11 #include "base/string_util.h" 12 #include "base/string_util.h"
12 #include "base/time.h" 13 #include "base/time.h"
13 #include "base/values.h" 14 #include "base/values.h"
14 #include "chrome/browser/bookmarks/bookmark_codec.h" 15 #include "chrome/browser/bookmarks/bookmark_codec.h"
15 #include "chrome/browser/bookmarks/bookmark_model.h" 16 #include "chrome/browser/bookmarks/bookmark_model.h"
16 #include "chrome/browser/history/history_types.h" 17 #include "chrome/browser/history/history_types.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 const char kFolderChildren[] = "<DL><p>"; 65 const char kFolderChildren[] = "<DL><p>";
65 // End of the children for a folder. 66 // End of the children for a folder.
66 const char kFolderChildrenEnd[] = "</DL><p>"; 67 const char kFolderChildrenEnd[] = "</DL><p>";
67 68
68 // Number of characters to indent by. 69 // Number of characters to indent by.
69 const size_t kIndentSize = 4; 70 const size_t kIndentSize = 4;
70 71
71 // Class responsible for the actual writing. 72 // Class responsible for the actual writing.
72 class Writer : public Task { 73 class Writer : public Task {
73 public: 74 public:
74 Writer(Value* bookmarks, const std::wstring& path) 75 Writer(Value* bookmarks, const FilePath& path)
75 : bookmarks_(bookmarks), 76 : bookmarks_(bookmarks),
76 path_(path) { 77 path_(path) {
77 } 78 }
78 79
79 virtual void Run() { 80 virtual void Run() {
80 if (!OpenFile()) 81 if (!OpenFile())
81 return; 82 return;
82 83
83 Value* roots; 84 Value* roots;
84 if (!Write(kHeader) || 85 if (!Write(kHeader) ||
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 } 294 }
294 } 295 }
295 return true; 296 return true;
296 } 297 }
297 298
298 // The BookmarkModel as a Value. This value was generated from the 299 // The BookmarkModel as a Value. This value was generated from the
299 // BookmarkCodec. 300 // BookmarkCodec.
300 scoped_ptr<Value> bookmarks_; 301 scoped_ptr<Value> bookmarks_;
301 302
302 // Path we're writing to. 303 // Path we're writing to.
303 std::wstring path_; 304 FilePath path_;
304 305
305 // File we're writing to. 306 // File we're writing to.
306 net::FileStream file_stream_; 307 net::FileStream file_stream_;
307 308
308 // How much we indent when writing a bookmark/folder. This is modified 309 // How much we indent when writing a bookmark/folder. This is modified
309 // via IncrementIndent and DecrementIndent. 310 // via IncrementIndent and DecrementIndent.
310 std::string indent_; 311 std::string indent_;
311 }; 312 };
312 313
313 } // namespace 314 } // namespace
314 315
315 void WriteBookmarks(MessageLoop* thread, 316 void WriteBookmarks(MessageLoop* thread,
316 BookmarkModel* model, 317 BookmarkModel* model,
317 const std::wstring& path) { 318 const std::wstring& path) {
318 // BookmarkModel isn't thread safe (nor would we want to lock it down 319 // BookmarkModel isn't thread safe (nor would we want to lock it down
319 // for the duration of the write), as such we make a copy of the 320 // for the duration of the write), as such we make a copy of the
320 // BookmarkModel using BookmarkCodec then write from that. 321 // BookmarkModel using BookmarkCodec then write from that.
321 BookmarkCodec codec; 322 BookmarkCodec codec;
322 scoped_ptr<Writer> writer(new Writer(codec.Encode(model), path)); 323 scoped_ptr<Writer> writer(new Writer(codec.Encode(model),
324 FilePath::FromWStringHack(path)));
323 if (thread) 325 if (thread)
324 thread->PostTask(FROM_HERE, writer.release()); 326 thread->PostTask(FROM_HERE, writer.release());
325 else 327 else
326 writer->Run(); 328 writer->Run();
327 } 329 }
328 330
329 } // namespace bookmark_html_writer 331 } // namespace bookmark_html_writer
OLDNEW
« no previous file with comments | « no previous file | chrome/common/unzip.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698