diff options
author | mirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-20 19:25:35 +0000 |
---|---|---|
committer | mirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-20 19:25:35 +0000 |
commit | 95940f106670b9259dcc25cdeb56722d857dbca0 (patch) | |
tree | c01a45b7c57df852b15f311f87e93c24743b43aa /chrome | |
parent | 233ee5d5b15c0846e69f82306ff0118592d3270c (diff) | |
download | chromium_src-95940f106670b9259dcc25cdeb56722d857dbca0.zip chromium_src-95940f106670b9259dcc25cdeb56722d857dbca0.tar.gz chromium_src-95940f106670b9259dcc25cdeb56722d857dbca0.tar.bz2 |
Revert 47675.
Instead of moving data types into common/, create a special class of IPC messages that live in the browser directory, specifically for importing browser-related data.
BUG=18774
TEST=none
Review URL: http://codereview.chromium.org/2095020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47827 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
30 files changed, 199 insertions, 236 deletions
diff --git a/chrome/browser/cocoa/import_progress_dialog.h b/chrome/browser/cocoa/import_progress_dialog.h index 85c08c7..41e401d 100644 --- a/chrome/browser/cocoa/import_progress_dialog.h +++ b/chrome/browser/cocoa/import_progress_dialog.h @@ -8,7 +8,7 @@ #import <Cocoa/Cocoa.h> #include "chrome/browser/importer/importer.h" -#include "chrome/common/importer_data_types.h" +#include "chrome/browser/importer/importer_data_types.h" class ImporterObserverBridge; diff --git a/chrome/browser/cocoa/import_settings_dialog.mm b/chrome/browser/cocoa/import_settings_dialog.mm index 2020113..77fb985 100644 --- a/chrome/browser/cocoa/import_settings_dialog.mm +++ b/chrome/browser/cocoa/import_settings_dialog.mm @@ -6,7 +6,7 @@ #include "base/mac_util.h" #include "base/sys_string_conversions.h" -#include "chrome/common/importer_data_types.h" +#include "chrome/browser/importer/importer_data_types.h" #include "chrome/browser/importer/importer_list.h" #include "chrome/browser/profile.h" diff --git a/chrome/browser/extensions/extension_bookmarks_module.cc b/chrome/browser/extensions/extension_bookmarks_module.cc index b44209e..8361b82 100644 --- a/chrome/browser/extensions/extension_bookmarks_module.cc +++ b/chrome/browser/extensions/extension_bookmarks_module.cc @@ -18,7 +18,7 @@ #include "chrome/browser/extensions/extension_message_service.h" #include "chrome/browser/extensions/extensions_quota_service.h" #include "chrome/browser/importer/importer.h" -#include "chrome/common/importer_data_types.h" +#include "chrome/browser/importer/importer_data_types.h" #include "chrome/browser/pref_service.h" #include "chrome/browser/profile.h" #include "chrome/common/notification_service.h" diff --git a/chrome/browser/first_run_mac.mm b/chrome/browser/first_run_mac.mm index 234de5e..16ef3e7 100644 --- a/chrome/browser/first_run_mac.mm +++ b/chrome/browser/first_run_mac.mm @@ -10,7 +10,7 @@ #import "chrome/browser/cocoa/first_run_dialog.h" #import "chrome/browser/cocoa/import_progress_dialog.h" #include "chrome/browser/importer/importer.h" -#include "chrome/common/importer_data_types.h" +#include "chrome/browser/importer/importer_data_types.h" #include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/shell_integration.h" #include "chrome/installer/util/google_update_constants.h" diff --git a/chrome/browser/first_run_win.cc b/chrome/browser/first_run_win.cc index 4c14df7..f12a75b 100644 --- a/chrome/browser/first_run_win.cc +++ b/chrome/browser/first_run_win.cc @@ -37,7 +37,7 @@ #include "chrome/browser/extensions/extension_updater.h" #include "chrome/browser/hang_monitor/hung_window_detector.h" #include "chrome/browser/importer/importer.h" -#include "chrome/common/importer_data_types.h" +#include "chrome/browser/importer/importer_data_types.h" #include "chrome/browser/pref_service.h" #include "chrome/browser/process_singleton.h" #include "chrome/browser/profile.h" diff --git a/chrome/browser/gtk/bookmark_bar_gtk.cc b/chrome/browser/gtk/bookmark_bar_gtk.cc index 6257bf4..f8d9808 100644 --- a/chrome/browser/gtk/bookmark_bar_gtk.cc +++ b/chrome/browser/gtk/bookmark_bar_gtk.cc @@ -31,7 +31,7 @@ #include "chrome/browser/gtk/tabstrip_origin_provider.h" #include "chrome/browser/gtk/tabs/tab_strip_gtk.h" #include "chrome/browser/gtk/view_id_util.h" -#include "chrome/common/importer_data_types.h" +#include "chrome/browser/importer/importer_data_types.h" #include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/ntp_background_util.h" #include "chrome/browser/pref_service.h" diff --git a/chrome/browser/gtk/first_run_dialog.cc b/chrome/browser/gtk/first_run_dialog.cc index a1d7dc2..ed4dfb9 100644 --- a/chrome/browser/gtk/first_run_dialog.cc +++ b/chrome/browser/gtk/first_run_dialog.cc @@ -10,7 +10,7 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/gtk/gtk_chrome_link_button.h" #include "chrome/browser/gtk/gtk_util.h" -#include "chrome/common/importer_data_types.h" +#include "chrome/browser/importer/importer_data_types.h" #include "chrome/browser/platform_util.h" #include "chrome/browser/process_singleton.h" #include "chrome/browser/shell_integration.h" diff --git a/chrome/browser/gtk/import_dialog_gtk.cc b/chrome/browser/gtk/import_dialog_gtk.cc index 0cb30e9..5af8aec 100644 --- a/chrome/browser/gtk/import_dialog_gtk.cc +++ b/chrome/browser/gtk/import_dialog_gtk.cc @@ -11,7 +11,7 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/gtk/accessible_widget_helper_gtk.h" #include "chrome/browser/gtk/gtk_util.h" -#include "chrome/common/importer_data_types.h" +#include "chrome/browser/importer/importer_data_types.h" #include "grit/generated_resources.h" #include "grit/locale_settings.h" diff --git a/chrome/browser/gtk/import_progress_dialog_gtk.h b/chrome/browser/gtk/import_progress_dialog_gtk.h index 7e3e310..a990ca7 100644 --- a/chrome/browser/gtk/import_progress_dialog_gtk.h +++ b/chrome/browser/gtk/import_progress_dialog_gtk.h @@ -8,7 +8,7 @@ #include <gtk/gtk.h> #include "chrome/browser/importer/importer.h" -#include "chrome/common/importer_data_types.h" +#include "chrome/browser/importer/importer_data_types.h" class Profile; diff --git a/chrome/browser/gtk/options/content_page_gtk.cc b/chrome/browser/gtk/options/content_page_gtk.cc index 2969086..dcdf53b 100644 --- a/chrome/browser/gtk/options/content_page_gtk.cc +++ b/chrome/browser/gtk/options/content_page_gtk.cc @@ -21,7 +21,7 @@ #include "chrome/browser/gtk/options/customize_sync_window_gtk.h" #include "chrome/browser/gtk/options/options_layout_gtk.h" #include "chrome/browser/gtk/options/passwords_exceptions_window_gtk.h" -#include "chrome/common/importer_data_types.h" +#include "chrome/browser/importer/importer_data_types.h" #include "chrome/browser/pref_service.h" #include "chrome/browser/sync/sync_ui_util.h" #include "chrome/common/chrome_switches.h" diff --git a/chrome/browser/history/history_types.cc b/chrome/browser/history/history_types.cc index 887abdb..aadd0af 100644 --- a/chrome/browser/history/history_types.cc +++ b/chrome/browser/history/history_types.cc @@ -12,6 +12,28 @@ using base::Time; namespace history { +// URLRow ---------------------------------------------------------------------- + +void URLRow::Swap(URLRow* other) { + std::swap(id_, other->id_); + url_.Swap(&other->url_); + title_.swap(other->title_); + std::swap(visit_count_, other->visit_count_); + std::swap(typed_count_, other->typed_count_); + std::swap(last_visit_, other->last_visit_); + std::swap(hidden_, other->hidden_); + std::swap(favicon_id_, other->favicon_id_); +} + +void URLRow::Initialize() { + id_ = 0; + visit_count_ = false; + typed_count_ = false; + last_visit_ = Time(); + hidden_ = false; + favicon_id_ = 0; +} + // VisitRow -------------------------------------------------------------------- VisitRow::VisitRow() diff --git a/chrome/browser/history/history_types.h b/chrome/browser/history/history_types.h index 45c4c20..c3fb5c6 100644 --- a/chrome/browser/history/history_types.h +++ b/chrome/browser/history/history_types.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -16,7 +16,6 @@ #include "chrome/browser/history/snippet.h" #include "chrome/common/page_transition_types.h" #include "chrome/common/ref_counted_util.h" -#include "chrome/common/url_row_type.h" #include "googleurl/src/gurl.h" namespace history { @@ -35,8 +34,143 @@ typedef std::vector<GURL> RedirectList; typedef int64 StarID; // Unique identifier for star entries. typedef int64 UIStarID; // Identifier for star entries that come from the UI. typedef int64 DownloadID; // Identifier for a download. +typedef int64 FavIconID; // For FavIcons. typedef int64 SegmentID; // URL segments for the most visited view. +// URLRow --------------------------------------------------------------------- + +typedef int64 URLID; + +// Holds all information globally associated with one URL (one row in the +// URL table). +// +// This keeps track of dirty bits, which are currently unused: +// +// TODO(brettw) the dirty bits are broken in a number of respects. First, the +// database will want to update them on a const object, so they need to be +// mutable. +// +// Second, there is a problem copying. If you make a copy of this structure +// (as we allow since we put this into vectors in various places) then the +// dirty bits will not be in sync for these copies. +class URLRow { + public: + URLRow() { + Initialize(); + } + + explicit URLRow(const GURL& url) : url_(url) { + // Initialize will not set the URL, so our initialization above will stay. + Initialize(); + } + + // We need to be able to set the id of a URLRow that's being passed through + // an IPC message. This constructor should probably not be used otherwise. + URLRow(const GURL& url, URLID id) : url_(url) { + // Initialize will not set the URL, so our initialization above will stay. + Initialize(); + // Initialize will zero the id_, so set it here. + id_ = id; + } + + virtual ~URLRow() {} + + URLID id() const { return id_; } + const GURL& url() const { return url_; } + + const std::wstring& title() const { + return title_; + } + void set_title(const std::wstring& title) { + // The title is frequently set to the same thing, so we don't bother + // updating unless the string has changed. + if (title != title_) { + title_ = title; + } + } + + int visit_count() const { + return visit_count_; + } + void set_visit_count(int visit_count) { + visit_count_ = visit_count; + } + + // Number of times the URL was typed in the Omnibox. + int typed_count() const { + return typed_count_; + } + void set_typed_count(int typed_count) { + typed_count_ = typed_count; + } + + base::Time last_visit() const { + return last_visit_; + } + void set_last_visit(base::Time last_visit) { + last_visit_ = last_visit; + } + + // If this is set, we won't autocomplete this URL. + bool hidden() const { + return hidden_; + } + void set_hidden(bool hidden) { + hidden_ = hidden; + } + + // ID of the favicon. A value of 0 means the favicon isn't known yet. + FavIconID favicon_id() const { return favicon_id_; } + void set_favicon_id(FavIconID favicon_id) { + favicon_id_ = favicon_id; + } + + // Swaps the contents of this URLRow with another, which allows it to be + // destructively copied without memory allocations. + // (Virtual because it's overridden by URLResult.) + virtual void Swap(URLRow* other); + + private: + // This class writes directly into this structure and clears our dirty bits + // when reading out of the DB. + friend class URLDatabase; + friend class HistoryBackend; + + // Initializes all values that need initialization to their defaults. + // This excludes objects which autoinitialize such as strings. + void Initialize(); + + // The row ID of this URL. Immutable except for the database which sets it + // when it pulls them out. + URLID id_; + + // The URL of this row. Immutable except for the database which sets it + // when it pulls them out. If clients want to change it, they must use + // the constructor to make a new one. + GURL url_; + + std::wstring title_; + + // Total number of times this URL has been visited. + int visit_count_; + + // Number of times this URL has been manually entered in the URL bar. + int typed_count_; + + // The date of the last visit of this URL, which saves us from having to + // loop up in the visit table for things like autocomplete and expiration. + base::Time last_visit_; + + // Indicates this entry should now be shown in typical UI or queries, this + // is usually for subframes. + bool hidden_; + + // The ID of the favicon for this url. + FavIconID favicon_id_; + + // We support the implicit copy constuctor and operator=. +}; + // VisitRow ------------------------------------------------------------------- typedef int64 VisitID; @@ -89,6 +223,20 @@ class VisitRow { // We pass around vectors of visits a lot typedef std::vector<VisitRow> VisitVector; +// Favicons ------------------------------------------------------------------- + +// Used by the importer to set favicons for imported bookmarks. +struct ImportedFavIconUsage { + // The URL of the favicon. + GURL favicon_url; + + // The raw png-encoded data. + std::vector<unsigned char> png_data; + + // The list of URLs using this favicon. + std::set<GURL> urls; +}; + // PageVisit ------------------------------------------------------------------ // Represents a simplified version of a visit for external users. Normally, diff --git a/chrome/browser/importer/firefox2_importer.h b/chrome/browser/importer/firefox2_importer.h index 1eebd4a..09a80d7 100644 --- a/chrome/browser/importer/firefox2_importer.h +++ b/chrome/browser/importer/firefox2_importer.h @@ -9,7 +9,7 @@ #include "base/file_path.h" #include "chrome/browser/importer/importer.h" -#include "chrome/common/importer_data_types.h" +#include "chrome/browser/importer/importer_data_types.h" #include "testing/gtest/include/gtest/gtest_prod.h" class TemplateURL; diff --git a/chrome/browser/importer/firefox3_importer.h b/chrome/browser/importer/firefox3_importer.h index bf921b7..f8bfa2f 100644 --- a/chrome/browser/importer/firefox3_importer.h +++ b/chrome/browser/importer/firefox3_importer.h @@ -13,7 +13,7 @@ #include "base/basictypes.h" #include "base/file_path.h" #include "chrome/browser/importer/importer.h" -#include "chrome/common/importer_data_types.h" +#include "chrome/browser/importer/importer_data_types.h" #include "googleurl/src/gurl.h" struct sqlite3; diff --git a/chrome/browser/importer/ie_importer.cc b/chrome/browser/importer/ie_importer.cc index 1cc3dc0..cae26ba 100644 --- a/chrome/browser/importer/ie_importer.cc +++ b/chrome/browser/importer/ie_importer.cc @@ -26,7 +26,7 @@ #include "base/win_util.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/importer/importer_bridge.h" -#include "chrome/common/importer_data_types.h" +#include "chrome/browser/importer/importer_data_types.h" #include "chrome/browser/password_manager/ie7_password.h" #include "chrome/browser/search_engines/template_url_model.h" #include "chrome/common/time_format.h" diff --git a/chrome/browser/importer/importer.h b/chrome/browser/importer/importer.h index 50b7a4d..d0ea428 100644 --- a/chrome/browser/importer/importer.h +++ b/chrome/browser/importer/importer.h @@ -15,7 +15,7 @@ #include "base/scoped_ptr.h" #include "base/time.h" #include "chrome/browser/bookmarks/bookmark_model_observer.h" -#include "chrome/common/importer_data_types.h" +#include "chrome/browser/importer/importer_data_types.h" #include "chrome/browser/importer/importer_list.h" #include "chrome/browser/importer/profile_writer.h" #include "chrome/common/notification_registrar.h" diff --git a/chrome/browser/importer/importer_bridge.h b/chrome/browser/importer/importer_bridge.h index 8f90e61..14025e6 100644 --- a/chrome/browser/importer/importer_bridge.h +++ b/chrome/browser/importer/importer_bridge.h @@ -13,7 +13,7 @@ #include "base/string16.h" #include "chrome/browser/importer/importer.h" -#include "chrome/common/importer_data_types.h" +#include "chrome/browser/importer/importer_data_types.h" // TODO: remove this, see friend declaration in ImporterBridge. #include "chrome/browser/importer/toolbar_importer.h" diff --git a/chrome/common/importer_data_types.h b/chrome/browser/importer/importer_data_types.h index 12ba3db..444cc45 100644 --- a/chrome/common/importer_data_types.h +++ b/chrome/browser/importer/importer_data_types.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_COMMON_IMPORTER_DATA_TYPES_H_ -#define CHROME_COMMON_IMPORTER_DATA_TYPES_H_ +#ifndef CHROME_BROWSER_IMPORTER_IMPORTER_DATA_TYPES_H_ +#define CHROME_BROWSER_IMPORTER_IMPORTER_DATA_TYPES_H_ #include <string> @@ -54,5 +54,5 @@ struct ProfileInfo { } // namespace importer -#endif // CHROME_COMMON_IMPORTER_DATA_TYPES_H_ +#endif // CHROME_BROWSER_IMPORTER_IMPORTER_DATA_TYPES_H_ diff --git a/chrome/browser/importer/importer_list.h b/chrome/browser/importer/importer_list.h index 3557043..c76aab3 100644 --- a/chrome/browser/importer/importer_list.h +++ b/chrome/browser/importer/importer_list.h @@ -10,7 +10,7 @@ #include "build/build_config.h" #include "base/basictypes.h" -#include "chrome/common/importer_data_types.h" +#include "chrome/browser/importer/importer_data_types.h" class Importer; diff --git a/chrome/browser/importer/importer_unittest.cc b/chrome/browser/importer/importer_unittest.cc index eaa4dc6..eac9bed 100644 --- a/chrome/browser/importer/importer_unittest.cc +++ b/chrome/browser/importer/importer_unittest.cc @@ -23,7 +23,7 @@ #include "chrome/browser/importer/ie_importer.h" #include "chrome/browser/importer/importer.h" #include "chrome/browser/importer/importer_bridge.h" -#include "chrome/common/importer_data_types.h" +#include "chrome/browser/importer/importer_data_types.h" #include "chrome/browser/password_manager/ie7_password.h" #include "chrome/browser/profile.h" #include "chrome/browser/search_engines/template_url.h" diff --git a/chrome/browser/importer/safari_importer.h b/chrome/browser/importer/safari_importer.h index 5465efd..c15ca30 100644 --- a/chrome/browser/importer/safari_importer.h +++ b/chrome/browser/importer/safari_importer.h @@ -13,7 +13,7 @@ #include "base/file_path.h" #include "chrome/common/sqlite_utils.h" -#include "chrome/common/importer_data_types.h" +#include "chrome/browser/importer/importer_data_types.h" #include "testing/gtest/include/gtest/gtest_prod.h" #if __OBJC__ diff --git a/chrome/browser/importer/toolbar_importer.h b/chrome/browser/importer/toolbar_importer.h index 0e13118..23f4291 100644 --- a/chrome/browser/importer/toolbar_importer.h +++ b/chrome/browser/importer/toolbar_importer.h @@ -12,7 +12,7 @@ #include <vector> #include "chrome/browser/importer/importer.h" -#include "chrome/common/importer_data_types.h" +#include "chrome/browser/importer/importer_data_types.h" #include "chrome/common/net/url_fetcher.h" #include "testing/gtest/include/gtest/gtest_prod.h" diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc index 8dd76b1..8ff3c42 100644 --- a/chrome/browser/views/bookmark_bar_view.cc +++ b/chrome/browser/views/bookmark_bar_view.cc @@ -19,7 +19,7 @@ #include "chrome/browser/bookmarks/bookmark_utils.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_theme_provider.h" -#include "chrome/common/importer_data_types.h" +#include "chrome/browser/importer/importer_data_types.h" #include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/pref_service.h" #include "chrome/browser/profile.h" diff --git a/chrome/browser/views/importer_view.cc b/chrome/browser/views/importer_view.cc index ec13c39..151badf 100644 --- a/chrome/browser/views/importer_view.cc +++ b/chrome/browser/views/importer_view.cc @@ -7,7 +7,7 @@ #include "app/l10n_util.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_window.h" -#include "chrome/common/importer_data_types.h" +#include "chrome/browser/importer/importer_data_types.h" #include "grit/generated_resources.h" #include "grit/locale_settings.h" #include "views/controls/button/checkbox.h" diff --git a/chrome/browser/views/importing_progress_view.h b/chrome/browser/views/importing_progress_view.h index d8a50b3..71fdc74 100644 --- a/chrome/browser/views/importing_progress_view.h +++ b/chrome/browser/views/importing_progress_view.h @@ -6,7 +6,7 @@ #define CHROME_BROWSER_VIEWS_IMPORTING_PROGRESS_VIEW_H_ #include "chrome/browser/importer/importer.h" -#include "chrome/common/importer_data_types.h" +#include "chrome/browser/importer/importer_data_types.h" #include "views/view.h" #include "views/window/dialog_delegate.h" #include "views/window/window.h" diff --git a/chrome/browser/views/options/content_page_view.cc b/chrome/browser/views/options/content_page_view.cc index 0e6b062..5a84125 100644 --- a/chrome/browser/views/options/content_page_view.cc +++ b/chrome/browser/views/options/content_page_view.cc @@ -19,7 +19,7 @@ #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/browser_window.h" -#include "chrome/common/importer_data_types.h" +#include "chrome/browser/importer/importer_data_types.h" #include "chrome/browser/profile.h" #include "chrome/browser/sync/sync_ui_util.h" #include "chrome/browser/views/importer_view.h" diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index cbbc0b2..b2dd03b 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1532,6 +1532,7 @@ 'browser/importer/importer.h', 'browser/importer/importer_bridge.cc', 'browser/importer/importer_bridge.h', + 'browser/importer/importer_data_types.h', 'browser/importer/importer_list.cc', 'browser/importer/importer_list.h', 'browser/importer/mork_reader.cc', diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi index d0da13e..4e1d884 100644 --- a/chrome/chrome_common.gypi +++ b/chrome/chrome_common.gypi @@ -51,7 +51,6 @@ 'common/geoposition.h', 'common/gpu_messages.h', 'common/gpu_messages_internal.h', - 'common/importer_data_types.h', 'common/logging_chrome.cc', 'common/logging_chrome.h', 'common/main_function_params.h', @@ -92,8 +91,6 @@ 'common/time_format.cc', 'common/time_format.h', 'common/transport_dib.h', - 'common/url_row_type.cc', - 'common/url_row_type.h', 'common/win_safe_util.cc', 'common/win_safe_util.h', ], diff --git a/chrome/common/url_row_type.cc b/chrome/common/url_row_type.cc deleted file mode 100644 index ab04a7a..0000000 --- a/chrome/common/url_row_type.cc +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "url_row_type.h" - -using base::Time; - -namespace history { - -void URLRow::Swap(URLRow* other) { - std::swap(id_, other->id_); - url_.Swap(&other->url_); - title_.swap(other->title_); - std::swap(visit_count_, other->visit_count_); - std::swap(typed_count_, other->typed_count_); - std::swap(last_visit_, other->last_visit_); - std::swap(hidden_, other->hidden_); - std::swap(favicon_id_, other->favicon_id_); -} - -void URLRow::Initialize() { - id_ = 0; - visit_count_ = false; - typed_count_ = false; - last_visit_ = Time(); - hidden_ = false; - favicon_id_ = 0; -} - -} // namespace history diff --git a/chrome/common/url_row_type.h b/chrome/common/url_row_type.h deleted file mode 100644 index 6ec004c..0000000 --- a/chrome/common/url_row_type.h +++ /dev/null @@ -1,174 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_COMMON_URL_ROW_TYPE_H_ -#define CHROME_COMMON_URL_ROW_TYPE_H_ - -#include <set> -#include <vector> - -#include "base/basictypes.h" -#include "base/time.h" -#include "googleurl/src/gurl.h" - -// This file includes the URLRow class and ImportedFavIconUsage struct, which -// need to be in the common directory because they're accessed by the importer -// process as well as the browser process. - -namespace history { - -// URLRow --------------------------------------------------------------------- - -typedef int64 URLID; -typedef int64 FavIconID; // For FavIcons. - -// Holds all information globally associated with one URL (one row in the -// URL table). -// -// This keeps track of dirty bits, which are currently unused: -// -// TODO(brettw) the dirty bits are broken in a number of respects. First, the -// database will want to update them on a const object, so they need to be -// mutable. -// -// Second, there is a problem copying. If you make a copy of this structure -// (as we allow since we put this into vectors in various places) then the -// dirty bits will not be in sync for these copies. -class URLRow { - public: - URLRow() { - Initialize(); - } - - explicit URLRow(const GURL& url) : url_(url) { - // Initialize will not set the URL, so our initialization above will stay. - Initialize(); - } - - // We need to be able to set the id of a URLRow that's being passed through - // an IPC message. This constructor should probably not be used otherwise. - URLRow(const GURL& url, URLID id) : url_(url) { - // Initialize will not set the URL, so our initialization above will stay. - Initialize(); - // Initialize will zero the id_, so set it here. - id_ = id; - } - - virtual ~URLRow() {} - - URLID id() const { return id_; } - const GURL& url() const { return url_; } - - const std::wstring& title() const { - return title_; - } - void set_title(const std::wstring& title) { - // The title is frequently set to the same thing, so we don't bother - // updating unless the string has changed. - if (title != title_) { - title_ = title; - } - } - - int visit_count() const { - return visit_count_; - } - void set_visit_count(int visit_count) { - visit_count_ = visit_count; - } - - // Number of times the URL was typed in the Omnibox. - int typed_count() const { - return typed_count_; - } - void set_typed_count(int typed_count) { - typed_count_ = typed_count; - } - - base::Time last_visit() const { - return last_visit_; - } - void set_last_visit(base::Time last_visit) { - last_visit_ = last_visit; - } - - // If this is set, we won't autocomplete this URL. - bool hidden() const { - return hidden_; - } - void set_hidden(bool hidden) { - hidden_ = hidden; - } - - // ID of the favicon. A value of 0 means the favicon isn't known yet. - FavIconID favicon_id() const { return favicon_id_; } - void set_favicon_id(FavIconID favicon_id) { - favicon_id_ = favicon_id; - } - - // Swaps the contents of this URLRow with another, which allows it to be - // destructively copied without memory allocations. - // (Virtual because it's overridden by URLResult.) - virtual void Swap(URLRow* other); - - private: - // This class writes directly into this structure and clears our dirty bits - // when reading out of the DB. - friend class URLDatabase; - friend class HistoryBackend; - - // Initializes all values that need initialization to their defaults. - // This excludes objects which autoinitialize such as strings. - void Initialize(); - - // The row ID of this URL. Immutable except for the database which sets it - // when it pulls them out. - URLID id_; - - // The URL of this row. Immutable except for the database which sets it - // when it pulls them out. If clients want to change it, they must use - // the constructor to make a new one. - GURL url_; - - std::wstring title_; - - // Total number of times this URL has been visited. - int visit_count_; - - // Number of times this URL has been manually entered in the URL bar. - int typed_count_; - - // The date of the last visit of this URL, which saves us from having to - // loop up in the visit table for things like autocomplete and expiration. - base::Time last_visit_; - - // Indicates this entry should now be shown in typical UI or queries, this - // is usually for subframes. - bool hidden_; - - // The ID of the favicon for this url. - FavIconID favicon_id_; - - // We support the implicit copy constuctor and operator=. -}; - -// Favicons ------------------------------------------------------------------- - -// Used by the importer to set favicons for imported bookmarks. -struct ImportedFavIconUsage { - // The URL of the favicon. - GURL favicon_url; - - // The raw png-encoded data. - std::vector<unsigned char> png_data; - - // The list of URLs using this favicon. - std::set<GURL> urls; -}; - -} // namespace history - -#endif // CHROME_COMMON_URL_ROW_TYPE_H_ - - |