summaryrefslogtreecommitdiffstats
path: root/chrome/browser/history
diff options
context:
space:
mode:
authormirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-20 19:25:35 +0000
committermirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-20 19:25:35 +0000
commit95940f106670b9259dcc25cdeb56722d857dbca0 (patch)
treec01a45b7c57df852b15f311f87e93c24743b43aa /chrome/browser/history
parent233ee5d5b15c0846e69f82306ff0118592d3270c (diff)
downloadchromium_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/browser/history')
-rw-r--r--chrome/browser/history/history_types.cc22
-rw-r--r--chrome/browser/history/history_types.h152
2 files changed, 172 insertions, 2 deletions
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,