diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-10 03:25:40 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-10 03:25:40 +0000 |
commit | fc3fc45793bbd882909b01e2c0f771741f4849ed (patch) | |
tree | fe0c38eea8c3615066355034ff934545b3aa7f89 /chrome/browser/bookmarks | |
parent | 4bcac78e6c353cd9823f559dc8c6181e824e88ce (diff) | |
download | chromium_src-fc3fc45793bbd882909b01e2c0f771741f4849ed.zip chromium_src-fc3fc45793bbd882909b01e2c0f771741f4849ed.tar.gz chromium_src-fc3fc45793bbd882909b01e2c0f771741f4849ed.tar.bz2 |
Re-check in some of my dynamic linking change.
We can't link in any more of these fixed .cc files because of a chain of
dependencies:
- temp_scaffolding_stubs defines the same symbols as these files
- removing the scaffolding pulls in more source
- pulling in that extra source breaks on Mac.
I have resigned myself to checking in this small bit.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9448 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/bookmarks')
-rw-r--r-- | chrome/browser/bookmarks/bookmark_model.cc | 30 | ||||
-rw-r--r-- | chrome/browser/bookmarks/bookmark_storage.cc | 29 | ||||
-rw-r--r-- | chrome/browser/bookmarks/bookmark_storage.h | 5 |
3 files changed, 41 insertions, 23 deletions
diff --git a/chrome/browser/bookmarks/bookmark_model.cc b/chrome/browser/bookmarks/bookmark_model.cc index 4280808..cb53639 100644 --- a/chrome/browser/bookmarks/bookmark_model.cc +++ b/chrome/browser/bookmarks/bookmark_model.cc @@ -5,6 +5,7 @@ #include "chrome/browser/bookmarks/bookmark_model.h" #include "base/gfx/png_decoder.h" +#include "build/build_config.h" #include "chrome/browser/bookmarks/bookmark_utils.h" #include "chrome/browser/bookmarks/bookmark_storage.h" #include "chrome/browser/profile.h" @@ -61,13 +62,15 @@ void BookmarkNode::Reset(const history::StarredEntry& entry) { BookmarkModel::BookmarkModel(Profile* profile) : profile_(profile), loaded_(false), -#pragma warning(suppress: 4355) // Okay to pass "this" here. - root_(this, GURL()), + ALLOW_THIS_IN_INITIALIZER_LIST(root_(this, GURL())), bookmark_bar_node_(NULL), other_node_(NULL), observers_(ObserverList<BookmarkModelObserver>::NOTIFY_EXISTING_ONLY), - waiting_for_history_load_(false), - loaded_signal_(CreateEvent(NULL, TRUE, FALSE, NULL)) { + waiting_for_history_load_(false) +#if defined(OS_WIN) + , loaded_signal_(CreateEvent(NULL, TRUE, FALSE, NULL)) +#endif +{ // Create the bookmark bar and other bookmarks folders. These always exist. CreateBookmarkNode(); CreateOtherBookmarksNode(); @@ -437,8 +440,12 @@ void BookmarkModel::DoneLoading() { loaded_ = true; +#if defined(OS_WIN) if (loaded_signal_.Get()) SetEvent(loaded_signal_.Get()); +#else + NOTIMPLEMENTED(); +#endif // Notify our direct observers. @@ -467,10 +474,15 @@ void BookmarkModel::RemoveAndDeleteNode(BookmarkNode* delete_me) { // allow duplicates we need to remove any entries that are still bookmarked. for (std::set<GURL>::iterator i = details.changed_urls.begin(); i != details.changed_urls.end(); ){ - if (IsBookmarkedNoLock(*i)) - i = details.changed_urls.erase(i); - else + if (IsBookmarkedNoLock(*i)) { + // When we erase the iterator pointing at the erasee is + // invalidated, so using i++ here within the "erase" call is + // important as it advances the iterator before passing the + // old value through to erase. + details.changed_urls.erase(i++); + } else { ++i; + } } } @@ -522,8 +534,12 @@ BookmarkNode* BookmarkModel::AddNode(BookmarkNode* parent, } void BookmarkModel::BlockTillLoaded() { +#if defined(OS_WIN) if (loaded_signal_.Get()) WaitForSingleObject(loaded_signal_.Get(), INFINITE); +#else + NOTIMPLEMENTED(); +#endif } BookmarkNode* BookmarkModel::GetNodeByID(BookmarkNode* node, int id) { diff --git a/chrome/browser/bookmarks/bookmark_storage.cc b/chrome/browser/bookmarks/bookmark_storage.cc index 4f2ae9f..64743e5 100644 --- a/chrome/browser/bookmarks/bookmark_storage.cc +++ b/chrome/browser/bookmarks/bookmark_storage.cc @@ -19,11 +19,11 @@ namespace { // Extension used for backup files (copy of main file created during startup). -const wchar_t* const kBackupExtension = L"bak"; +const FilePath::CharType kBackupExtension[] = FILE_PATH_LITERAL("bak"); // Extension for the temporary file. We write to the temp file than move to // kBookmarksFileName. -const wchar_t* const kTmpExtension = L"tmp"; +const FilePath::CharType kTmpExtension[] = FILE_PATH_LITERAL("tmp"); // How often we save. const int kSaveDelayMS = 2500; @@ -36,10 +36,9 @@ BookmarkStorage::BookmarkStorage(Profile* profile, BookmarkModel* model) : model_(model), ALLOW_THIS_IN_INITIALIZER_LIST(save_factory_(this)), backend_thread_(g_browser_process->file_thread()) { - std::wstring path = profile->GetPath().ToWStringHack(); - file_util::AppendToPath(&path, chrome::kBookmarksFileName); - std::wstring tmp_history_path = profile->GetPath().ToWStringHack(); - file_util::AppendToPath(&tmp_history_path, chrome::kHistoryBookmarksFileName); + FilePath path = profile->GetPath().Append(chrome::kBookmarksFileName); + FilePath tmp_history_path = + profile->GetPath().Append(chrome::kHistoryBookmarksFileName); backend_ = new BookmarkStorageBackend(path, tmp_history_path); } @@ -115,13 +114,12 @@ void BookmarkStorage::SaveNow() { // BookmarkStorageBackend ------------------------------------------------------ BookmarkStorageBackend::BookmarkStorageBackend( - const std::wstring& path, - const std::wstring& tmp_history_path) - : path_(path), - tmp_history_path_(tmp_history_path) { + const FilePath& path, + const FilePath& tmp_history_path) + : path_(path.ToWStringHack()), + tmp_history_path_(tmp_history_path.ToWStringHack()) { // Make a backup of the current file. - std::wstring backup_path = path; - file_util::ReplaceExtension(&backup_path, kBackupExtension); + FilePath backup_path = path.ReplaceExtension(kBackupExtension); file_util::CopyFile(path, backup_path); } @@ -135,8 +133,11 @@ void BookmarkStorageBackend::Write(Value* value) { JSONWriter::Write(value, true, &content); // Write to a temp file, then rename. - std::wstring tmp_file = path_; - file_util::ReplaceExtension(&tmp_file, kTmpExtension); + // TODO(port): this code was all written to use wstrings; needs cleaning up + // for FilePath. + FilePath tmp_file_filepath = + FilePath::FromWStringHack(path_).ReplaceExtension(kTmpExtension); + std::wstring tmp_file = tmp_file_filepath.ToWStringHack(); int bytes_written = file_util::WriteFile(tmp_file, content.c_str(), static_cast<int>(content.length())); diff --git a/chrome/browser/bookmarks/bookmark_storage.h b/chrome/browser/bookmarks/bookmark_storage.h index f63aa81..59b91a8 100644 --- a/chrome/browser/bookmarks/bookmark_storage.h +++ b/chrome/browser/bookmarks/bookmark_storage.h @@ -10,6 +10,7 @@ class BookmarkModel; class BookmarkStorageBackend; +class FilePath; class Profile; class MessageLoop; class Value; @@ -75,8 +76,8 @@ class BookmarkStorage : public base::RefCountedThreadSafe<BookmarkStorage> { class BookmarkStorageBackend : public base::RefCountedThreadSafe<BookmarkStorageBackend> { public: - explicit BookmarkStorageBackend(const std::wstring& path, - const std::wstring& tmp_histor_path); + explicit BookmarkStorageBackend(const FilePath& path, + const FilePath& tmp_history_path); // Writes the specified value to disk. This takes ownership of |value| and // deletes it when done. |