diff options
Diffstat (limited to 'chrome/browser/history')
40 files changed, 35 insertions, 892 deletions
diff --git a/chrome/browser/history/android/android_cache_database.h b/chrome/browser/history/android/android_cache_database.h index 3fb977b..c0ae941 100644 --- a/chrome/browser/history/android/android_cache_database.h +++ b/chrome/browser/history/android/android_cache_database.h @@ -8,7 +8,7 @@ #include "base/files/file_path.h" #include "base/gtest_prod_util.h" #include "base/time/time.h" -#include "chrome/browser/history/android/android_history_types.h" +#include "components/history/core/android/android_history_types.h" #include "sql/connection.h" #include "sql/init_status.h" diff --git a/chrome/browser/history/android/android_history_provider_service.h b/chrome/browser/history/android/android_history_provider_service.h index d25a0cd..a3f16af 100644 --- a/chrome/browser/history/android/android_history_provider_service.h +++ b/chrome/browser/history/android/android_history_provider_service.h @@ -8,7 +8,7 @@ #include "base/callback.h" #include "base/memory/ref_counted.h" #include "base/task/cancelable_task_tracker.h" -#include "chrome/browser/history/android/android_history_types.h" +#include "components/history/core/android/android_history_types.h" #include "sql/statement.h" class Profile; diff --git a/chrome/browser/history/android/android_history_provider_service_unittest.cc b/chrome/browser/history/android/android_history_provider_service_unittest.cc index 51c4186..bf2202c 100644 --- a/chrome/browser/history/android/android_history_provider_service_unittest.cc +++ b/chrome/browser/history/android/android_history_provider_service_unittest.cc @@ -8,12 +8,12 @@ #include "base/task/cancelable_task_tracker.h" #include "base/time/time.h" #include "chrome/browser/bookmarks/bookmark_model_factory.h" -#include "chrome/browser/history/android/android_history_types.h" #include "chrome/common/chrome_constants.h" #include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile_manager.h" #include "components/bookmarks/test/bookmark_test_helpers.h" +#include "components/history/core/android/android_history_types.h" #include "content/public/browser/browser_thread.h" #include "content/public/test/test_browser_thread.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/browser/history/android/android_history_types.cc b/chrome/browser/history/android/android_history_types.cc deleted file mode 100644 index b587249..0000000 --- a/chrome/browser/history/android/android_history_types.cc +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright (c) 2012 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 "chrome/browser/history/android/android_history_types.h" - -namespace history { - -namespace { -// The column name defined in android.provider.Browser.BookmarkColumns -const char* const kAndroidBookmarkColumn[] = { - "_id", - "url", - "title", - "created", - "date", - "visits", - "favicon", - "bookmark", - "raw_url", -}; - -// The column name defined in android.provider.Browser.SearchColumns -const char* const kAndroidSearchColumn[] = { - "_id", - "search", - "date", -}; - -class BookmarkIDMapping : public std::map<std::string, - HistoryAndBookmarkRow::ColumnID> { - public: - BookmarkIDMapping() { - COMPILE_ASSERT(arraysize(kAndroidBookmarkColumn) <= - HistoryAndBookmarkRow::COLUMN_END, - Array_size_must_not_exceed_enum); - for (size_t i = 0; i < arraysize(kAndroidBookmarkColumn); ++i) { - (*this)[kAndroidBookmarkColumn[i]] = - static_cast<HistoryAndBookmarkRow::ColumnID>(i); - } - } -}; - -// The mapping from Android column name to ColumnID; It is initialized -// once it used. -BookmarkIDMapping* g_bookmark_id_mapping = NULL; - -class SearchIDMapping : public std::map<std::string, - SearchRow::ColumnID> { - public: - SearchIDMapping() { - COMPILE_ASSERT(arraysize(kAndroidSearchColumn) <= SearchRow::COLUMN_END, - Array_size_must_not_exceed_enum); - for (size_t i = 0; i < arraysize(kAndroidSearchColumn); ++i) { - (*this)[kAndroidSearchColumn[i]] = - static_cast<SearchRow::ColumnID>(i); - } - } -}; - -// The mapping from Android column name to ColumnID; It is initialized -// once it used. -SearchIDMapping* g_search_id_mapping = NULL; - -} // namespace - -HistoryAndBookmarkRow::HistoryAndBookmarkRow() - : id_(0), - created_(base::Time()), - last_visit_time_(base::Time()), - visit_count_(0), - is_bookmark_(false), - parent_id_(0), - url_id_(0) { -} - -HistoryAndBookmarkRow::~HistoryAndBookmarkRow() { -} - -std::string HistoryAndBookmarkRow::GetAndroidName(ColumnID id) { - return kAndroidBookmarkColumn[id]; -} - -HistoryAndBookmarkRow::ColumnID HistoryAndBookmarkRow::GetColumnID( - const std::string& name) { - if (!g_bookmark_id_mapping) - g_bookmark_id_mapping = new BookmarkIDMapping(); - - BookmarkIDMapping::const_iterator i = g_bookmark_id_mapping->find(name); - if (i == g_bookmark_id_mapping->end()) - return HistoryAndBookmarkRow::COLUMN_END; - else - return i->second; -} - -SearchRow::SearchRow() - : id_(0), - keyword_id_(0) { -} - -SearchRow::~SearchRow() { -} - -std::string SearchRow::GetAndroidName(ColumnID id) { - return kAndroidSearchColumn[id]; -} - -SearchRow::ColumnID SearchRow::GetColumnID( - const std::string& name) { - if (!g_search_id_mapping) - g_search_id_mapping = new SearchIDMapping(); - - SearchIDMapping::const_iterator i = g_search_id_mapping->find(name); - if (i == g_search_id_mapping->end()) - return SearchRow:: COLUMN_END; - else - return i->second; -} - -AndroidURLRow::AndroidURLRow() - : id(0), - url_id(0) { -} - -AndroidURLRow::~AndroidURLRow() { -} - -SearchTermRow::SearchTermRow() - : id(0) { -} - -SearchTermRow::~SearchTermRow() { -} - -AndroidStatement::AndroidStatement(sql::Statement* statement, int favicon_index) - : statement_(statement), - favicon_index_(favicon_index) { -} - -AndroidStatement::~AndroidStatement() { -} - -} // namespace history. diff --git a/chrome/browser/history/android/android_history_types.h b/chrome/browser/history/android/android_history_types.h deleted file mode 100644 index a27b99e..0000000 --- a/chrome/browser/history/android/android_history_types.h +++ /dev/null @@ -1,332 +0,0 @@ -// Copyright (c) 2012 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_BROWSER_HISTORY_ANDROID_ANDROID_HISTORY_TYPES_H_ -#define CHROME_BROWSER_HISTORY_ANDROID_ANDROID_HISTORY_TYPES_H_ - -#include <map> - -#include "base/memory/scoped_ptr.h" -#include "chrome/browser/history/history_types.h" -#include "components/history/core/browser/keyword_id.h" -#include "sql/statement.h" - -namespace sql { -class Statement; -} - -namespace history { - -typedef int64 AndroidURLID; -typedef int64 SearchTermID; - -// Wraps all columns needed to support android.provider.Browser.BookmarkColumns. -// It is used in insert() and update() to specify the columns need to insert or -// update. -// The column is not valid until it set. Using is_valid() to find out whether -// the specific column could be used. -// -// The defult copy constructor is used. -class HistoryAndBookmarkRow { - public: - enum ColumnID { - ID, - URL, - TITLE, - CREATED, - LAST_VISIT_TIME, - VISIT_COUNT, - FAVICON, - BOOKMARK, - RAW_URL, - PARENT_ID, - URL_ID, - COLUMN_END // This must be the last. - }; - - HistoryAndBookmarkRow(); - virtual ~HistoryAndBookmarkRow(); - - // Returns the column name defined in Android. - static std::string GetAndroidName(ColumnID id); - - static ColumnID GetColumnID(const std::string& name); - - // URLs for the page. - void set_url(const GURL& url) { - set_value_explicitly(URL); - url_ = url; - } - const GURL& url() const { - return url_; - } - - // Raw input URL - void set_raw_url(const std::string& raw_url) { - set_value_explicitly(RAW_URL); - raw_url_ = raw_url; - } - const std::string& raw_url() const { - return raw_url_; - } - - // The title of page. - void set_title(const base::string16& title) { - set_value_explicitly(TITLE); - title_ = title; - } - const base::string16& title() const { - return title_; - } - - // The page's first visit time. - void set_created(const base::Time created) { - set_value_explicitly(CREATED); - created_ = created; - } - const base::Time& created() const { - return created_; - } - - // The page's last visit time. - void set_last_visit_time(const base::Time last_visit_time) { - set_value_explicitly(LAST_VISIT_TIME); - last_visit_time_ = last_visit_time; - } - const base::Time& last_visit_time() const { - return last_visit_time_; - } - - // The visit times - void set_visit_count(int visit_count) { - set_value_explicitly(VISIT_COUNT); - visit_count_ = visit_count; - } - int visit_count() const { - return visit_count_; - } - - // Whether the page is bookmarked. - void set_is_bookmark(bool is_bookmark) { - set_value_explicitly(BOOKMARK); - is_bookmark_ = is_bookmark; - } - bool is_bookmark() const { - return is_bookmark_; - } - - // The favicon related to page if any. - void set_favicon(const scoped_refptr<base::RefCountedMemory>& data) { - set_value_explicitly(FAVICON); - favicon_ = data; - } - const scoped_refptr<base::RefCountedMemory>& favicon() const { - return favicon_; - } - - bool favicon_valid() const { - return favicon_.get() && favicon_->size(); - } - - // The id of android url. - void set_id(AndroidURLID id) { - set_value_explicitly(ID); - id_ = id; - } - AndroidURLID id() const { - return id_; - } - - // The id of the parent folder containing the bookmark, if any. - void set_parent_id(int64 parent_id) { - set_value_explicitly(PARENT_ID); - parent_id_ = parent_id; - } - const int64 parent_id() const { - return parent_id_; - } - - // The internal URLID - void set_url_id(URLID url_id) { - set_value_explicitly(URL_ID); - url_id_ = url_id; - } - URLID url_id() const { - return url_id_; - } - - // Returns true if the given |id| has been set explicitly. - bool is_value_set_explicitly(ColumnID id) const { - return values_set_.find(id) != values_set_.end(); - } - - private: - void set_value_explicitly(ColumnID id) { - values_set_.insert(id); - } - - AndroidURLID id_; - GURL url_; - std::string raw_url_; - base::string16 title_; - base::Time created_; - base::Time last_visit_time_; - scoped_refptr<base::RefCountedMemory> favicon_; - int visit_count_; - bool is_bookmark_; - int64 parent_id_; - URLID url_id_; - - // Used to find whether a column has been set a value explicitly. - std::set<ColumnID> values_set_; - - // We support the implicit copy constuctor and operator=. -}; - -// Wraps all columns needed to support android.provider.Browser.SearchColumns. -// It is used in insert() and update() to specify the columns need to insert or -// update. -// -// The column is not valid until it set. Using is_valid() to find out whether -// the specific column could be used. -// -// The defult copy constructor is used. -class SearchRow { - public: - enum ColumnID { - ID, - SEARCH_TERM, - SEARCH_TIME, - URL, - KEYWORD_ID, - COLUMN_END - }; - - SearchRow(); - virtual ~SearchRow(); - - // Returns the column name defined in Android. - static std::string GetAndroidName(ColumnID id); - - static ColumnID GetColumnID(const std::string& name); - - SearchTermID id() const { - return id_; - } - void set_id(SearchTermID id) { - set_value_explicitly(SearchRow::ID); - id_ = id; - } - - const base::string16& search_term() const { - return search_term_; - } - void set_search_term(const base::string16& search_term) { - set_value_explicitly(SearchRow::SEARCH_TERM); - search_term_ = search_term; - } - - const base::Time search_time() const { - return search_time_; - } - void set_search_time(const base::Time& time) { - set_value_explicitly(SearchRow::SEARCH_TIME); - search_time_ = time; - } - - const GURL& url() const { - return url_; - } - void set_url(const GURL& url) { - set_value_explicitly(SearchRow::URL); - url_ = url; - } - - KeywordID keyword_id() const { - return keyword_id_; - } - void set_keyword_id(KeywordID keyword_id) { - set_value_explicitly(SearchRow::KEYWORD_ID); - keyword_id_ = keyword_id; - } - - // Returns true if the given |id| has been set explicitly. - bool is_value_set_explicitly(ColumnID id) const { - return values_set_.find(id) != values_set_.end(); - } - - private: - void set_value_explicitly(ColumnID id) { - values_set_.insert(id); - } - - SearchTermID id_; - base::string16 search_term_; - base::Time search_time_; - GURL url_; - KeywordID keyword_id_; - - // Used to find whether a column has been set a value. - std::set<ColumnID> values_set_; - - // We support the implicit copy constuctor and operator=. -}; - -// Defines the row stored in android_urls table. -struct AndroidURLRow { - AndroidURLRow(); - ~AndroidURLRow(); - - // The unique id of the row - AndroidURLID id; - // The corresponding URLID in the url table. - URLID url_id; - // The orignal URL string passed in by client. - std::string raw_url; -}; - -// Defines the row of keyword_cache table. -struct SearchTermRow { - SearchTermRow(); - ~SearchTermRow(); - - // The unique id of the row. - SearchTermID id; - // The keyword. - base::string16 term; - // The last visit time. - base::Time last_visit_time; -}; - -// This class wraps the sql statement and favicon column index in statement if -// any. It is returned by AndroidProviderBackend::Query(). -// -// Using favicon_index() to get the index of favicon; The value of that column -// is the Favicon ID, Client should call HistoryService::GetFavicon() to get the -// actual value. -class AndroidStatement { - public: - AndroidStatement(sql::Statement* statement, int favicon_index); - ~AndroidStatement(); - - sql::Statement* statement() { - return statement_.get(); - } - - // The favicon index in statement; -1 is returned if favicon is not in - // the statement. - int favicon_index() const { - return favicon_index_; - } - - private: - scoped_ptr<sql::Statement> statement_; - int favicon_index_; - - DISALLOW_COPY_AND_ASSIGN(AndroidStatement); -}; - -} // namespace history - -#endif // CHROME_BROWSER_HISTORY_ANDROID_ANDROID_HISTORY_TYPES_H_ diff --git a/chrome/browser/history/android/android_history_types_unittest.cc b/chrome/browser/history/android/android_history_types_unittest.cc deleted file mode 100644 index ef82030..0000000 --- a/chrome/browser/history/android/android_history_types_unittest.cc +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) 2012 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 "chrome/browser/history/android/android_history_types.h" - -#include "testing/gtest/include/gtest/gtest.h" - -namespace history { - -TEST(AndroidHistoryTypesTest, TestGetBookmarkColumnID) { - EXPECT_EQ(HistoryAndBookmarkRow::ID, - HistoryAndBookmarkRow::GetColumnID("_id")); - EXPECT_EQ(HistoryAndBookmarkRow::URL, - HistoryAndBookmarkRow::GetColumnID("url")); - EXPECT_EQ(HistoryAndBookmarkRow::TITLE, - HistoryAndBookmarkRow::GetColumnID("title")); - EXPECT_EQ(HistoryAndBookmarkRow::CREATED, - HistoryAndBookmarkRow::GetColumnID("created")); - EXPECT_EQ(HistoryAndBookmarkRow::LAST_VISIT_TIME, - HistoryAndBookmarkRow::GetColumnID("date")); - EXPECT_EQ(HistoryAndBookmarkRow::VISIT_COUNT, - HistoryAndBookmarkRow::GetColumnID("visits")); - EXPECT_EQ(HistoryAndBookmarkRow::FAVICON, - HistoryAndBookmarkRow::GetColumnID("favicon")); - EXPECT_EQ(HistoryAndBookmarkRow::BOOKMARK, - HistoryAndBookmarkRow::GetColumnID("bookmark")); - EXPECT_EQ(HistoryAndBookmarkRow::RAW_URL, - HistoryAndBookmarkRow::GetColumnID("raw_url")); -} - -TEST(AndroidHistoryTypesTest, TestGetSearchColumnID) { - EXPECT_EQ(SearchRow::ID, SearchRow::GetColumnID("_id")); - EXPECT_EQ(SearchRow::SEARCH_TERM, SearchRow::GetColumnID("search")); - EXPECT_EQ(SearchRow::SEARCH_TIME, SearchRow::GetColumnID("date")); -} - -} // namespace history diff --git a/chrome/browser/history/android/android_provider_backend.h b/chrome/browser/history/android/android_provider_backend.h index 62acfe7..bc9552d 100644 --- a/chrome/browser/history/android/android_provider_backend.h +++ b/chrome/browser/history/android/android_provider_backend.h @@ -15,10 +15,10 @@ #include "base/memory/scoped_ptr.h" #include "base/memory/scoped_vector.h" #include "chrome/browser/history/android/android_cache_database.h" -#include "chrome/browser/history/android/android_history_types.h" #include "chrome/browser/history/android/sql_handler.h" #include "chrome/browser/history/history_backend.h" #include "chrome/browser/history/history_notifications.h" +#include "components/history/core/android/android_history_types.h" #include "sql/statement.h" #include "sql/transaction.h" diff --git a/chrome/browser/history/android/android_urls_database.h b/chrome/browser/history/android/android_urls_database.h index fda6354..b1d071b 100644 --- a/chrome/browser/history/android/android_urls_database.h +++ b/chrome/browser/history/android/android_urls_database.h @@ -5,7 +5,7 @@ #ifndef CHROME_BROWSER_HISTORY_ANDROID_ANDROID_URLS_DATABASE_H_ #define CHROME_BROWSER_HISTORY_ANDROID_ANDROID_URLS_DATABASE_H_ -#include "chrome/browser/history/android/android_history_types.h" +#include "components/history/core/android/android_history_types.h" namespace history { diff --git a/chrome/browser/history/android/sql_handler.h b/chrome/browser/history/android/sql_handler.h index 43c57ee..dd6ec62 100644 --- a/chrome/browser/history/android/sql_handler.h +++ b/chrome/browser/history/android/sql_handler.h @@ -5,7 +5,7 @@ #ifndef CHROME_BROWSER_HISTORY_ANDROID_SQL_HANDLER_H_ #define CHROME_BROWSER_HISTORY_ANDROID_SQL_HANDLER_H_ -#include "chrome/browser/history/android/android_history_types.h" +#include "components/history/core/android/android_history_types.h" namespace history { diff --git a/chrome/browser/history/android/sqlite_cursor.cc b/chrome/browser/history/android/sqlite_cursor.cc index 1b53624..b255385 100644 --- a/chrome/browser/history/android/sqlite_cursor.cc +++ b/chrome/browser/history/android/sqlite_cursor.cc @@ -10,7 +10,7 @@ #include "base/bind.h" #include "base/logging.h" #include "chrome/browser/favicon/favicon_service.h" -#include "chrome/browser/history/android/android_history_types.h" +#include "components/history/core/android/android_history_types.h" #include "content/public/browser/browser_thread.h" #include "jni/SQLiteCursor_jni.h" #include "sql/statement.h" diff --git a/chrome/browser/history/android/sqlite_cursor.h b/chrome/browser/history/android/sqlite_cursor.h index 48edc67..c53e109 100644 --- a/chrome/browser/history/android/sqlite_cursor.h +++ b/chrome/browser/history/android/sqlite_cursor.h @@ -16,8 +16,8 @@ #include "base/synchronization/waitable_event.h" #include "base/task/cancelable_task_tracker.h" #include "chrome/browser/history/android/android_history_provider_service.h" -#include "chrome/browser/history/history_types.h" #include "components/favicon_base/favicon_callback.h" +#include "components/history/core/browser/history_types.h" class FaviconService; diff --git a/chrome/browser/history/android/sqlite_cursor_unittest.cc b/chrome/browser/history/android/sqlite_cursor_unittest.cc index 4c26105..f113c1d 100644 --- a/chrome/browser/history/android/sqlite_cursor_unittest.cc +++ b/chrome/browser/history/android/sqlite_cursor_unittest.cc @@ -17,7 +17,6 @@ #include "chrome/browser/favicon/chrome_favicon_client_factory.h" #include "chrome/browser/favicon/favicon_service.h" #include "chrome/browser/history/android/android_history_provider_service.h" -#include "chrome/browser/history/android/android_history_types.h" #include "chrome/browser/history/android/android_time.h" #include "chrome/browser/history/history_service.h" #include "chrome/browser/history/history_service_factory.h" @@ -26,6 +25,7 @@ #include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile_manager.h" #include "components/bookmarks/test/bookmark_test_helpers.h" +#include "components/history/core/android/android_history_types.h" #include "content/public/browser/browser_thread.h" #include "content/public/test/test_browser_thread.h" #include "content/public/test/test_utils.h" diff --git a/chrome/browser/history/download_database.cc b/chrome/browser/history/download_database.cc index 4fa418e..9461e45 100644 --- a/chrome/browser/history/download_database.cc +++ b/chrome/browser/history/download_database.cc @@ -18,7 +18,7 @@ #include "base/time/time.h" #include "build/build_config.h" #include "chrome/browser/history/download_row.h" -#include "chrome/browser/history/history_types.h" +#include "components/history/core/browser/history_types.h" #include "content/public/browser/download_interrupt_reasons.h" #include "content/public/browser/download_item.h" #include "sql/statement.h" diff --git a/chrome/browser/history/expire_history_backend.h b/chrome/browser/history/expire_history_backend.h index 3cb8e80..c4519f6 100644 --- a/chrome/browser/history/expire_history_backend.h +++ b/chrome/browser/history/expire_history_backend.h @@ -14,7 +14,7 @@ #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/time/time.h" -#include "chrome/browser/history/history_types.h" +#include "components/history/core/browser/history_types.h" class GURL; class TestingProfile; diff --git a/chrome/browser/history/history_backend.h b/chrome/browser/history/history_backend.h index 293595c..b6ac8b9 100644 --- a/chrome/browser/history/history_backend.h +++ b/chrome/browser/history/history_backend.h @@ -19,15 +19,15 @@ #include "base/task/cancelable_task_tracker.h" #include "chrome/browser/history/expire_history_backend.h" #include "chrome/browser/history/history_database.h" -#include "chrome/browser/history/history_types.h" #include "chrome/browser/history/thumbnail_database.h" #include "chrome/browser/history/visit_tracker.h" +#include "components/history/core/browser/history_types.h" #include "components/history/core/browser/keyword_id.h" #include "components/visitedlink/browser/visitedlink_delegate.h" #include "sql/init_status.h" #if defined(OS_ANDROID) -#include "chrome/browser/history/android/android_history_types.h" +#include "components/history/core/android/android_history_types.h" #endif class HistoryURLProvider; diff --git a/chrome/browser/history/history_notifications.h b/chrome/browser/history/history_notifications.h index 3386b2f..ca5cba8 100644 --- a/chrome/browser/history/history_notifications.h +++ b/chrome/browser/history/history_notifications.h @@ -10,7 +10,7 @@ #include <set> #include "chrome/browser/history/history_details.h" -#include "chrome/browser/history/history_types.h" +#include "components/history/core/browser/history_types.h" #include "components/history/core/browser/keyword_id.h" #include "url/gurl.h" diff --git a/chrome/browser/history/history_service.cc b/chrome/browser/history/history_service.cc index 4c61734..81e10d3 100644 --- a/chrome/browser/history/history_service.cc +++ b/chrome/browser/history/history_service.cc @@ -35,7 +35,6 @@ #include "chrome/browser/history/download_row.h" #include "chrome/browser/history/history_backend.h" #include "chrome/browser/history/history_notifications.h" -#include "chrome/browser/history/history_types.h" #include "chrome/browser/history/in_memory_history_backend.h" #include "chrome/browser/history/in_memory_url_index.h" #include "chrome/browser/history/top_sites.h" @@ -51,6 +50,7 @@ #include "chrome/common/url_constants.h" #include "components/dom_distiller/core/url_constants.h" #include "components/history/core/browser/history_client.h" +#include "components/history/core/browser/history_types.h" #include "components/history/core/browser/in_memory_database.h" #include "components/history/core/browser/keyword_search_term.h" #include "components/history/core/common/thumbnail_score.h" diff --git a/chrome/browser/history/history_types.cc b/chrome/browser/history/history_types.cc deleted file mode 100644 index 5e733cc..0000000 --- a/chrome/browser/history/history_types.cc +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (c) 2012 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 "chrome/browser/history/history_types.h" - -#include <limits> - -#include "base/logging.h" -#include "base/stl_util.h" - -namespace history { - -// VisitRow -------------------------------------------------------------------- - -VisitRow::VisitRow() - : visit_id(0), - url_id(0), - referring_visit(0), - transition(ui::PAGE_TRANSITION_LINK), - segment_id(0) { -} - -VisitRow::VisitRow(URLID arg_url_id, - base::Time arg_visit_time, - VisitID arg_referring_visit, - ui::PageTransition arg_transition, - SegmentID arg_segment_id) - : visit_id(0), - url_id(arg_url_id), - visit_time(arg_visit_time), - referring_visit(arg_referring_visit), - transition(arg_transition), - segment_id(arg_segment_id) { -} - -VisitRow::~VisitRow() { -} - -// QueryURLResult ------------------------------------------------------------- - -QueryURLResult::QueryURLResult() : success(false) { -} - -QueryURLResult::~QueryURLResult() { -} - -// HistoryAddPageArgs --------------------------------------------------------- - -HistoryAddPageArgs::HistoryAddPageArgs() - : context_id(NULL), - page_id(0), - transition(ui::PAGE_TRANSITION_LINK), - visit_source(SOURCE_BROWSED), - did_replace_entry(false) {} - -HistoryAddPageArgs::HistoryAddPageArgs( - const GURL& url, - base::Time time, - ContextID context_id, - int32 page_id, - const GURL& referrer, - const history::RedirectList& redirects, - ui::PageTransition transition, - VisitSource source, - bool did_replace_entry) - : url(url), - time(time), - context_id(context_id), - page_id(page_id), - referrer(referrer), - redirects(redirects), - transition(transition), - visit_source(source), - did_replace_entry(did_replace_entry) { -} - -HistoryAddPageArgs::~HistoryAddPageArgs() {} - -// VisitDatabaseObserver ------------------------------------------------------- - -VisitDatabaseObserver::~VisitDatabaseObserver() {} - -} // namespace history diff --git a/chrome/browser/history/history_types.h b/chrome/browser/history/history_types.h deleted file mode 100644 index c50856b..0000000 --- a/chrome/browser/history/history_types.h +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (c) 2012 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_BROWSER_HISTORY_HISTORY_TYPES_H_ -#define CHROME_BROWSER_HISTORY_HISTORY_TYPES_H_ - -#include "components/history/core/browser/history_types.h" -#include "ui/base/page_transition_types.h" - -namespace content { -class WebContents; -} - -namespace history { - -// Identifier for a context to scope page ids. (ContextIDs are used in -// comparisons only and are never dereferenced.) -// NB: The use of WebContents here is temporary; when the dependency on content -// is broken, some other type will take its place. -typedef content::WebContents* ContextID; - -// VisitRow ------------------------------------------------------------------- - -// Holds all information associated with a specific visit. A visit holds time -// and referrer information for one time a URL is visited. -class VisitRow { - public: - VisitRow(); - VisitRow(URLID arg_url_id, - base::Time arg_visit_time, - VisitID arg_referring_visit, - ui::PageTransition arg_transition, - SegmentID arg_segment_id); - ~VisitRow(); - - // ID of this row (visit ID, used a a referrer for other visits). - VisitID visit_id; - - // Row ID into the URL table of the URL that this page is. - URLID url_id; - - base::Time visit_time; - - // Indicates another visit that was the referring page for this one. - // 0 indicates no referrer. - VisitID referring_visit; - - // A combination of bits from PageTransition. - ui::PageTransition transition; - - // The segment id (see visitsegment_database.*). - // If 0, the segment id is null in the table. - SegmentID segment_id; - - // Record how much time a user has this visit starting from the user - // opened this visit to the user closed or ended this visit. - // This includes both active and inactive time as long as - // the visit was present. - base::TimeDelta visit_duration; - - // Compares two visits based on dates, for sorting. - bool operator<(const VisitRow& other) { - return visit_time < other.visit_time; - } - - // We allow the implicit copy constuctor and operator=. -}; - -// We pass around vectors of visits a lot -typedef std::vector<VisitRow> VisitVector; - -// The basic information associated with a visit (timestamp, type of visit), -// used by HistoryBackend::AddVisits() to create new visits for a URL. -typedef std::pair<base::Time, ui::PageTransition> VisitInfo; - -// QueryURLResult ------------------------------------------------------------- - -// QueryURLResult encapsulates the result of a call to HistoryBackend::QueryURL. -struct QueryURLResult { - QueryURLResult(); - ~QueryURLResult(); - - // Indicates whether the call to HistoryBackend::QueryURL was successfull - // or not. If false, then both |row| and |visits| fields are undefined. - bool success; - URLRow row; - VisitVector visits; -}; - -// Navigation ----------------------------------------------------------------- - -// Marshalling structure for AddPage. -struct HistoryAddPageArgs { - // The default constructor is equivalent to: - // - // HistoryAddPageArgs( - // GURL(), base::Time(), NULL, 0, GURL(), - // history::RedirectList(), ui::PAGE_TRANSITION_LINK, - // SOURCE_BROWSED, false) - HistoryAddPageArgs(); - HistoryAddPageArgs(const GURL& url, - base::Time time, - ContextID context_id, - int32 page_id, - const GURL& referrer, - const history::RedirectList& redirects, - ui::PageTransition transition, - VisitSource source, - bool did_replace_entry); - ~HistoryAddPageArgs(); - - GURL url; - base::Time time; - - ContextID context_id; - int32 page_id; - - GURL referrer; - history::RedirectList redirects; - ui::PageTransition transition; - VisitSource visit_source; - bool did_replace_entry; -}; - -// Abbreviated information about a visit. -struct BriefVisitInfo { - URLID url_id; - base::Time time; - ui::PageTransition transition; -}; - -// An observer of VisitDatabase. -class VisitDatabaseObserver { - public: - virtual ~VisitDatabaseObserver(); - virtual void OnAddVisit(const BriefVisitInfo& info) = 0; -}; - -} // namespace history - -#endif // CHROME_BROWSER_HISTORY_HISTORY_TYPES_H_ diff --git a/chrome/browser/history/history_types_unittest.cc b/chrome/browser/history/history_types_unittest.cc deleted file mode 100644 index 80c84e0..0000000 --- a/chrome/browser/history/history_types_unittest.cc +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (c) 2011 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 "base/strings/utf_string_conversions.h" -#include "chrome/browser/history/history_types.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace history { - -namespace { - -// Validates the consistency of the given history result. We just make sure -// that the URL rows match the indices structure. The unit tests themselves -// test the index structure to verify things are in the right order, so we -// don't need to. -void CheckHistoryResultConsistency(const QueryResults& result) { - for (size_t i = 0; i < result.size(); i++) { - size_t match_count; - const size_t* matches = result.MatchesForURL(result[i].url(), &match_count); - - bool found = false; - for (size_t match = 0; match < match_count; match++) { - if (matches[match] == i) { - found = true; - break; - } - } - - EXPECT_TRUE(found) << "The URL had no index referring to it."; - } -} - -const char kURL1[] = "http://www.google.com/"; -const char kURL2[] = "http://news.google.com/"; - -// Adds kURL1 twice and kURL2 once. -void AddSimpleData(QueryResults* results) { - GURL url1(kURL1); - GURL url2(kURL2); - URLResult result1(url1, base::Time::Now()); - URLResult result2(url1, base::Time::Now()); - URLResult result3(url2, base::Time::Now()); - - // The URLResults are invalid after being inserted. - results->AppendURLBySwapping(&result1); - results->AppendURLBySwapping(&result2); - results->AppendURLBySwapping(&result3); - CheckHistoryResultConsistency(*results); -} - -} // namespace - -// Tests insertion and deletion by range. -TEST(HistoryQueryResult, DeleteRange) { - GURL url1(kURL1); - GURL url2(kURL2); - QueryResults results; - AddSimpleData(&results); - - // Make sure the first URL is in there twice. The indices can be in either - // order. - size_t match_count; - const size_t* matches = results.MatchesForURL(url1, &match_count); - ASSERT_EQ(2U, match_count); - EXPECT_TRUE((matches[0] == 0 && matches[1] == 1) || - (matches[0] == 1 && matches[1] == 0)); - - // Check the second one. - matches = results.MatchesForURL(url2, &match_count); - ASSERT_EQ(1U, match_count); - EXPECT_TRUE(matches[0] == 2); - - // Delete the first instance of the first URL. - results.DeleteRange(0, 0); - CheckHistoryResultConsistency(results); - - // Check the two URLs. - matches = results.MatchesForURL(url1, &match_count); - ASSERT_EQ(1U, match_count); - EXPECT_TRUE(matches[0] == 0); - matches = results.MatchesForURL(url2, &match_count); - ASSERT_EQ(1U, match_count); - EXPECT_TRUE(matches[0] == 1); - - // Now delete everything and make sure it's deleted. - results.DeleteRange(0, 1); - EXPECT_EQ(0U, results.size()); - EXPECT_FALSE(results.MatchesForURL(url1, NULL)); - EXPECT_FALSE(results.MatchesForURL(url2, NULL)); -} - -// Tests insertion and deletion by URL. -TEST(HistoryQueryResult, ResultDeleteURL) { - GURL url1(kURL1); - GURL url2(kURL2); - QueryResults results; - AddSimpleData(&results); - - // Delete the first URL. - results.DeleteURL(url1); - CheckHistoryResultConsistency(results); - EXPECT_EQ(1U, results.size()); - - // The first one should be gone, and the second one should be at [0]. - size_t match_count; - EXPECT_FALSE(results.MatchesForURL(url1, NULL)); - const size_t* matches = results.MatchesForURL(url2, &match_count); - ASSERT_EQ(1U, match_count); - EXPECT_TRUE(matches[0] == 0); - - // Delete the second URL, there should be nothing left. - results.DeleteURL(url2); - EXPECT_EQ(0U, results.size()); - EXPECT_FALSE(results.MatchesForURL(url2, NULL)); -} - -} // namespace history diff --git a/chrome/browser/history/in_memory_url_index.h b/chrome/browser/history/in_memory_url_index.h index 43b1595..6399dcb 100644 --- a/chrome/browser/history/in_memory_url_index.h +++ b/chrome/browser/history/in_memory_url_index.h @@ -19,9 +19,9 @@ #include "base/strings/string16.h" #include "base/task/cancelable_task_tracker.h" #include "chrome/browser/history/history_db_task.h" -#include "chrome/browser/history/history_types.h" #include "chrome/browser/history/in_memory_url_index_types.h" #include "chrome/browser/history/scored_history_match.h" +#include "components/history/core/browser/history_types.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" #include "sql/connection.h" diff --git a/chrome/browser/history/in_memory_url_index_types.h b/chrome/browser/history/in_memory_url_index_types.h index 4191036..bd23160 100644 --- a/chrome/browser/history/in_memory_url_index_types.h +++ b/chrome/browser/history/in_memory_url_index_types.h @@ -10,7 +10,7 @@ #include <vector> #include "base/strings/string16.h" -#include "chrome/browser/history/history_types.h" +#include "components/history/core/browser/history_types.h" #include "url/gurl.h" namespace history { diff --git a/chrome/browser/history/scored_history_match.h b/chrome/browser/history/scored_history_match.h index 2b2cf7e..eb8f4cb 100644 --- a/chrome/browser/history/scored_history_match.h +++ b/chrome/browser/history/scored_history_match.h @@ -10,9 +10,9 @@ #include <vector> #include "base/strings/string16.h" -#include "chrome/browser/history/history_types.h" #include "chrome/browser/history/in_memory_url_index_types.h" #include "components/history/core/browser/history_match.h" +#include "components/history/core/browser/history_types.h" #include "testing/gtest/include/gtest/gtest_prod.h" namespace history { diff --git a/chrome/browser/history/thumbnail_database.h b/chrome/browser/history/thumbnail_database.h index 72c8901..14942f1 100644 --- a/chrome/browser/history/thumbnail_database.h +++ b/chrome/browser/history/thumbnail_database.h @@ -9,7 +9,7 @@ #include "base/gtest_prod_util.h" #include "base/memory/ref_counted.h" -#include "chrome/browser/history/history_types.h" +#include "components/history/core/browser/history_types.h" #include "sql/connection.h" #include "sql/init_status.h" #include "sql/meta_table.h" diff --git a/chrome/browser/history/top_sites.h b/chrome/browser/history/top_sites.h index d8f9c29..ea5dce4 100644 --- a/chrome/browser/history/top_sites.h +++ b/chrome/browser/history/top_sites.h @@ -10,7 +10,7 @@ #include "base/gtest_prod_util.h" #include "base/memory/ref_counted.h" #include "chrome/browser/history/history_service.h" -#include "chrome/browser/history/history_types.h" +#include "components/history/core/browser/history_types.h" #include "components/history/core/browser/top_sites_observer.h" #include "components/history/core/common/thumbnail_score.h" #include "third_party/skia/include/core/SkColor.h" diff --git a/chrome/browser/history/top_sites_backend.h b/chrome/browser/history/top_sites_backend.h index 3865e4b..51700c9 100644 --- a/chrome/browser/history/top_sites_backend.h +++ b/chrome/browser/history/top_sites_backend.h @@ -9,7 +9,7 @@ #include "base/files/file_path.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" -#include "chrome/browser/history/history_types.h" +#include "components/history/core/browser/history_types.h" namespace base { class CancelableTaskTracker; diff --git a/chrome/browser/history/top_sites_cache.h b/chrome/browser/history/top_sites_cache.h index 1269d3b..de3ee6d 100644 --- a/chrome/browser/history/top_sites_cache.h +++ b/chrome/browser/history/top_sites_cache.h @@ -9,8 +9,8 @@ #include <utility> #include "base/memory/ref_counted.h" -#include "chrome/browser/history/history_types.h" #include "chrome/browser/history/url_utils.h" +#include "components/history/core/browser/history_types.h" #include "url/gurl.h" class GURL; diff --git a/chrome/browser/history/top_sites_database.cc b/chrome/browser/history/top_sites_database.cc index c258db3..1fe4c25 100644 --- a/chrome/browser/history/top_sites_database.cc +++ b/chrome/browser/history/top_sites_database.cc @@ -9,8 +9,8 @@ #include "base/metrics/histogram.h" #include "base/strings/string_split.h" #include "base/strings/string_util.h" -#include "chrome/browser/history/history_types.h" #include "chrome/browser/history/top_sites.h" +#include "components/history/core/browser/history_types.h" #include "components/history/core/common/thumbnail_score.h" #include "sql/connection.h" #include "sql/recovery.h" diff --git a/chrome/browser/history/top_sites_database.h b/chrome/browser/history/top_sites_database.h index 9659d2a..0a86936 100644 --- a/chrome/browser/history/top_sites_database.h +++ b/chrome/browser/history/top_sites_database.h @@ -9,7 +9,7 @@ #include <string> #include "base/gtest_prod_util.h" -#include "chrome/browser/history/history_types.h" +#include "components/history/core/browser/history_types.h" #include "sql/meta_table.h" namespace base { diff --git a/chrome/browser/history/top_sites_database_unittest.cc b/chrome/browser/history/top_sites_database_unittest.cc index 9ec6719..b5bbbb2 100644 --- a/chrome/browser/history/top_sites_database_unittest.cc +++ b/chrome/browser/history/top_sites_database_unittest.cc @@ -8,10 +8,10 @@ #include "base/files/scoped_temp_dir.h" #include "base/path_service.h" #include "base/strings/utf_string_conversions.h" -#include "chrome/browser/history/history_types.h" #include "chrome/browser/history/top_sites_database.h" #include "chrome/common/chrome_paths.h" #include "chrome/tools/profiles/thumbnail-inl.h" +#include "components/history/core/browser/history_types.h" #include "sql/connection.h" #include "sql/recovery.h" #include "sql/test/scoped_error_ignorer.h" diff --git a/chrome/browser/history/top_sites_impl.h b/chrome/browser/history/top_sites_impl.h index 23702e0..28d8c0c 100644 --- a/chrome/browser/history/top_sites_impl.h +++ b/chrome/browser/history/top_sites_impl.h @@ -20,9 +20,9 @@ #include "base/time/time.h" #include "base/timer/timer.h" #include "chrome/browser/history/history_service.h" -#include "chrome/browser/history/history_types.h" #include "chrome/browser/history/top_sites.h" #include "chrome/browser/history/top_sites_backend.h" +#include "components/history/core/browser/history_types.h" #include "components/history/core/browser/page_usage_data.h" #include "components/history/core/common/thumbnail_score.h" #include "third_party/skia/include/core/SkColor.h" diff --git a/chrome/browser/history/top_sites_impl_unittest.cc b/chrome/browser/history/top_sites_impl_unittest.cc index 7afd738..aa4b0bc 100644 --- a/chrome/browser/history/top_sites_impl_unittest.cc +++ b/chrome/browser/history/top_sites_impl_unittest.cc @@ -12,7 +12,6 @@ #include "chrome/browser/history/history_db_task.h" #include "chrome/browser/history/history_notifications.h" #include "chrome/browser/history/history_service_factory.h" -#include "chrome/browser/history/history_types.h" #include "chrome/browser/history/history_unittest_base.h" #include "chrome/browser/history/top_sites.h" #include "chrome/browser/history/top_sites_cache.h" @@ -20,6 +19,7 @@ #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" #include "chrome/test/base/testing_profile.h" +#include "components/history/core/browser/history_types.h" #include "content/public/browser/notification_service.h" #include "content/public/test/test_browser_thread.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/browser/history/typed_url_syncable_service.h b/chrome/browser/history/typed_url_syncable_service.h index c1b835f..02dff54 100644 --- a/chrome/browser/history/typed_url_syncable_service.h +++ b/chrome/browser/history/typed_url_syncable_service.h @@ -9,7 +9,7 @@ #include <vector> #include "chrome/browser/history/history_notifications.h" -#include "chrome/browser/history/history_types.h" +#include "components/history/core/browser/history_types.h" #include "sync/api/sync_change.h" #include "sync/api/sync_data.h" #include "sync/api/sync_error.h" diff --git a/chrome/browser/history/typed_url_syncable_service_unittest.cc b/chrome/browser/history/typed_url_syncable_service_unittest.cc index 8f3b912..77069cd 100644 --- a/chrome/browser/history/typed_url_syncable_service_unittest.cc +++ b/chrome/browser/history/typed_url_syncable_service_unittest.cc @@ -9,7 +9,7 @@ #include "base/memory/scoped_ptr.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/history/history_backend.h" -#include "chrome/browser/history/history_types.h" +#include "components/history/core/browser/history_types.h" #include "content/public/browser/notification_types.h" #include "sync/api/fake_sync_change_processor.h" #include "sync/api/sync_change_processor_wrapper_for_test.h" diff --git a/chrome/browser/history/visit_database.h b/chrome/browser/history/visit_database.h index b8a175e..8f50848 100644 --- a/chrome/browser/history/visit_database.h +++ b/chrome/browser/history/visit_database.h @@ -7,7 +7,7 @@ #include <vector> -#include "chrome/browser/history/history_types.h" +#include "components/history/core/browser/history_types.h" namespace sql { class Connection; diff --git a/chrome/browser/history/visit_filter.cc b/chrome/browser/history/visit_filter.cc index 0a5ab74..9147dd73 100644 --- a/chrome/browser/history/visit_filter.cc +++ b/chrome/browser/history/visit_filter.cc @@ -10,7 +10,7 @@ #include "base/logging.h" #include "base/time/time.h" -#include "chrome/browser/history/history_types.h" +#include "components/history/core/browser/history_types.h" namespace history { diff --git a/chrome/browser/history/visit_filter_unittest.cc b/chrome/browser/history/visit_filter_unittest.cc index f100ad7..8953d75 100644 --- a/chrome/browser/history/visit_filter_unittest.cc +++ b/chrome/browser/history/visit_filter_unittest.cc @@ -8,7 +8,7 @@ #include "base/logging.h" #include "base/time/time.h" -#include "chrome/browser/history/history_types.h" +#include "components/history/core/browser/history_types.h" #include "testing/gtest/include/gtest/gtest.h" namespace { diff --git a/chrome/browser/history/visit_tracker.h b/chrome/browser/history/visit_tracker.h index 00b0c46..890a889 100644 --- a/chrome/browser/history/visit_tracker.h +++ b/chrome/browser/history/visit_tracker.h @@ -9,7 +9,7 @@ #include <vector> #include "base/basictypes.h" -#include "chrome/browser/history/history_types.h" +#include "components/history/core/browser/history_types.h" namespace history { diff --git a/chrome/browser/history/visitsegment_database.h b/chrome/browser/history/visitsegment_database.h index b224288..2302978 100644 --- a/chrome/browser/history/visitsegment_database.h +++ b/chrome/browser/history/visitsegment_database.h @@ -6,7 +6,7 @@ #define CHROME_BROWSER_HISTORY_VISITSEGMENT_DATABASE_H_ #include "base/basictypes.h" -#include "chrome/browser/history/history_types.h" +#include "components/history/core/browser/history_types.h" class PageUsageData; diff --git a/chrome/browser/history/web_history_service.h b/chrome/browser/history/web_history_service.h index 119b6e9..2e7c7e9 100644 --- a/chrome/browser/history/web_history_service.h +++ b/chrome/browser/history/web_history_service.h @@ -8,8 +8,8 @@ #include <set> #include "base/memory/weak_ptr.h" -#include "chrome/browser/history/history_types.h" #include "chrome/browser/profiles/profile.h" +#include "components/history/core/browser/history_types.h" #include "components/keyed_service/core/keyed_service.h" namespace base { |