| Index: chrome/browser/predictors/autocomplete_action_predictor_unittest.cc
 | 
| diff --git a/chrome/browser/autocomplete/network_action_predictor_unittest.cc b/chrome/browser/predictors/autocomplete_action_predictor_unittest.cc
 | 
| similarity index 75%
 | 
| rename from chrome/browser/autocomplete/network_action_predictor_unittest.cc
 | 
| rename to chrome/browser/predictors/autocomplete_action_predictor_unittest.cc
 | 
| index 25bff10c5c4285ad28dfcd9bc840efb889b784ae..afc3ecedea120f2ef382104fe2b3819cbbd32dff 100644
 | 
| --- a/chrome/browser/autocomplete/network_action_predictor_unittest.cc
 | 
| +++ b/chrome/browser/predictors/autocomplete_action_predictor_unittest.cc
 | 
| @@ -2,7 +2,7 @@
 | 
|  // Use of this source code is governed by a BSD-style license that can be
 | 
|  // found in the LICENSE file.
 | 
|  
 | 
| -#include "chrome/browser/autocomplete/network_action_predictor.h"
 | 
| +#include "chrome/browser/predictors/autocomplete_action_predictor.h"
 | 
|  
 | 
|  #include "base/command_line.h"
 | 
|  #include "base/memory/ref_counted.h"
 | 
| @@ -22,6 +22,7 @@
 | 
|  #include "testing/gtest/include/gtest/gtest.h"
 | 
|  
 | 
|  using content::BrowserThread;
 | 
| +using predictors::AutocompleteActionPredictor;
 | 
|  
 | 
|  namespace {
 | 
|  
 | 
| @@ -32,56 +33,58 @@ struct TestUrlInfo {
 | 
|    string16 user_text;
 | 
|    int number_of_hits;
 | 
|    int number_of_misses;
 | 
| -  NetworkActionPredictor::Action expected_action;
 | 
| +  AutocompleteActionPredictor::Action expected_action;
 | 
|  } test_url_db[] = {
 | 
|    { GURL("http://www.testsite.com/a.html"),
 | 
|      ASCIIToUTF16("Test - site - just a test"), 1,
 | 
|      ASCIIToUTF16("j"), 5, 0,
 | 
| -    NetworkActionPredictor::ACTION_PRERENDER },
 | 
| +    AutocompleteActionPredictor::ACTION_PRERENDER },
 | 
|    { GURL("http://www.testsite.com/b.html"),
 | 
|      ASCIIToUTF16("Test - site - just a test"), 1,
 | 
|      ASCIIToUTF16("ju"), 3, 0,
 | 
| -    NetworkActionPredictor::ACTION_PRERENDER },
 | 
| +    AutocompleteActionPredictor::ACTION_PRERENDER },
 | 
|    { GURL("http://www.testsite.com/c.html"),
 | 
|      ASCIIToUTF16("Test - site - just a test"), 5,
 | 
|      ASCIIToUTF16("just"), 3, 1,
 | 
| -    NetworkActionPredictor::ACTION_PRECONNECT },
 | 
| +    AutocompleteActionPredictor::ACTION_PRECONNECT },
 | 
|    { GURL("http://www.testsite.com/d.html"),
 | 
|      ASCIIToUTF16("Test - site - just a test"), 5,
 | 
|      ASCIIToUTF16("just"), 3, 0,
 | 
| -    NetworkActionPredictor::ACTION_PRERENDER },
 | 
| +    AutocompleteActionPredictor::ACTION_PRERENDER },
 | 
|    { GURL("http://www.testsite.com/e.html"),
 | 
|      ASCIIToUTF16("Test - site - just a test"), 8,
 | 
|      ASCIIToUTF16("just"), 3, 1,
 | 
| -    NetworkActionPredictor::ACTION_PRECONNECT },
 | 
| +    AutocompleteActionPredictor::ACTION_PRECONNECT },
 | 
|    { GURL("http://www.testsite.com/f.html"),
 | 
|      ASCIIToUTF16("Test - site - just a test"), 8,
 | 
|      ASCIIToUTF16("just"), 3, 0,
 | 
| -    NetworkActionPredictor::ACTION_PRERENDER },
 | 
| +    AutocompleteActionPredictor::ACTION_PRERENDER },
 | 
|    { GURL("http://www.testsite.com/g.html"),
 | 
|      ASCIIToUTF16("Test - site - just a test"), 12,
 | 
|      ASCIIToUTF16(""), 5, 0,
 | 
| -    NetworkActionPredictor::ACTION_NONE },
 | 
| +    AutocompleteActionPredictor::ACTION_NONE },
 | 
|    { GURL("http://www.testsite.com/h.html"),
 | 
|      ASCIIToUTF16("Test - site - just a test"), 21,
 | 
|      ASCIIToUTF16("just a test"), 2, 0,
 | 
| -    NetworkActionPredictor::ACTION_NONE },
 | 
| +    AutocompleteActionPredictor::ACTION_NONE },
 | 
|    { GURL("http://www.testsite.com/i.html"),
 | 
|      ASCIIToUTF16("Test - site - just a test"), 28,
 | 
|      ASCIIToUTF16("just a test"), 2, 0,
 | 
| -    NetworkActionPredictor::ACTION_NONE }
 | 
| +    AutocompleteActionPredictor::ACTION_NONE }
 | 
|  };
 | 
|  
 | 
|  }  // end namespace
 | 
|  
 | 
| -class NetworkActionPredictorTest : public testing::Test {
 | 
| +namespace predictors {
 | 
| +
 | 
| +class AutocompleteActionPredictorTest : public testing::Test {
 | 
|   public:
 | 
| -  NetworkActionPredictorTest()
 | 
| +  AutocompleteActionPredictorTest()
 | 
|        : loop_(MessageLoop::TYPE_DEFAULT),
 | 
|          ui_thread_(BrowserThread::UI, &loop_),
 | 
|          db_thread_(BrowserThread::DB, &loop_),
 | 
|          file_thread_(BrowserThread::FILE, &loop_),
 | 
| -        predictor_(new NetworkActionPredictor(&profile_)) {
 | 
| +        predictor_(new AutocompleteActionPredictor(&profile_)) {
 | 
|    }
 | 
|  
 | 
|    void SetUp() {
 | 
| @@ -103,10 +106,10 @@ class NetworkActionPredictorTest : public testing::Test {
 | 
|    }
 | 
|  
 | 
|   protected:
 | 
| -  typedef NetworkActionPredictor::DBCacheKey DBCacheKey;
 | 
| -  typedef NetworkActionPredictor::DBCacheValue DBCacheValue;
 | 
| -  typedef NetworkActionPredictor::DBCacheMap DBCacheMap;
 | 
| -  typedef NetworkActionPredictor::DBIdCacheMap DBIdCacheMap;
 | 
| +  typedef AutocompleteActionPredictor::DBCacheKey DBCacheKey;
 | 
| +  typedef AutocompleteActionPredictor::DBCacheValue DBCacheValue;
 | 
| +  typedef AutocompleteActionPredictor::DBCacheMap DBCacheMap;
 | 
| +  typedef AutocompleteActionPredictor::DBIdCacheMap DBIdCacheMap;
 | 
|  
 | 
|    void AddAllRowsToHistory() {
 | 
|      for (size_t i = 0; i < arraysize(test_url_db); ++i)
 | 
| @@ -131,9 +134,9 @@ class NetworkActionPredictorTest : public testing::Test {
 | 
|      return url_db->AddURL(row);
 | 
|    }
 | 
|  
 | 
| -  NetworkActionPredictorDatabase::Row CreateRowFromTestUrlInfo(
 | 
| +  AutocompleteActionPredictorTable::Row CreateRowFromTestUrlInfo(
 | 
|        const TestUrlInfo& test_row) const {
 | 
| -    NetworkActionPredictorDatabase::Row row;
 | 
| +    AutocompleteActionPredictorTable::Row row;
 | 
|      row.id = guid::GenerateGUID();
 | 
|      row.user_text = test_row.user_text;
 | 
|      row.url = test_row.url;
 | 
| @@ -148,22 +151,23 @@ class NetworkActionPredictorTest : public testing::Test {
 | 
|    }
 | 
|  
 | 
|    std::string AddRow(const TestUrlInfo& test_row) {
 | 
| -    NetworkActionPredictor::DBCacheKey key = { test_row.user_text,
 | 
| -                                               test_row.url };
 | 
| -    NetworkActionPredictorDatabase::Row row =
 | 
| +    AutocompleteActionPredictor::DBCacheKey key = { test_row.user_text,
 | 
| +                                                    test_row.url };
 | 
| +    AutocompleteActionPredictorTable::Row row =
 | 
|          CreateRowFromTestUrlInfo(test_row);
 | 
| -    predictor_->AddRow(key, row);
 | 
| +    predictor_->AddAndUpdateRows(
 | 
| +        AutocompleteActionPredictorTable::Rows(1, row),
 | 
| +        AutocompleteActionPredictorTable::Rows());
 | 
|  
 | 
|      return row.id;
 | 
|    }
 | 
|  
 | 
| -  void UpdateRow(NetworkActionPredictor::DBCacheKey key,
 | 
| -                 const NetworkActionPredictorDatabase::Row& row) {
 | 
| -    NetworkActionPredictor::DBCacheMap::iterator it =
 | 
| -        db_cache()->find(key);
 | 
| -    ASSERT_TRUE(it != db_cache()->end());
 | 
| -
 | 
| -    predictor_->UpdateRow(it, row);
 | 
| +  void UpdateRow(const AutocompleteActionPredictorTable::Row& row) {
 | 
| +    AutocompleteActionPredictor::DBCacheKey key = { row.user_text, row.url };
 | 
| +    ASSERT_TRUE(db_cache()->find(key) != db_cache()->end());
 | 
| +    predictor_->AddAndUpdateRows(
 | 
| +        AutocompleteActionPredictorTable::Rows(),
 | 
| +        AutocompleteActionPredictorTable::Rows(1, row));
 | 
|    }
 | 
|  
 | 
|    void DeleteAllRows() {
 | 
| @@ -175,7 +179,7 @@ class NetworkActionPredictorTest : public testing::Test {
 | 
|    }
 | 
|  
 | 
|    void DeleteOldIdsFromCaches(
 | 
| -      std::vector<NetworkActionPredictorDatabase::Row::Id>* id_list) {
 | 
| +      std::vector<AutocompleteActionPredictorTable::Row::Id>* id_list) {
 | 
|      HistoryService* history_service =
 | 
|          profile_.GetHistoryService(Profile::EXPLICIT_ACCESS);
 | 
|      ASSERT_TRUE(history_service);
 | 
| @@ -186,13 +190,13 @@ class NetworkActionPredictorTest : public testing::Test {
 | 
|      predictor_->DeleteOldIdsFromCaches(url_db, id_list);
 | 
|    }
 | 
|  
 | 
| -  NetworkActionPredictor* predictor() { return predictor_.get(); }
 | 
| +  AutocompleteActionPredictor* predictor() { return predictor_.get(); }
 | 
|  
 | 
|    DBCacheMap* db_cache() { return &predictor_->db_cache_; }
 | 
|    DBIdCacheMap* db_id_cache() { return &predictor_->db_id_cache_; }
 | 
|  
 | 
|    static int maximum_days_to_keep_entry() {
 | 
| -    return NetworkActionPredictor::kMaximumDaysToKeepEntry;
 | 
| +    return AutocompleteActionPredictor::kMaximumDaysToKeepEntry;
 | 
|    }
 | 
|  
 | 
|   private:
 | 
| @@ -201,11 +205,11 @@ class NetworkActionPredictorTest : public testing::Test {
 | 
|    content::TestBrowserThread db_thread_;
 | 
|    content::TestBrowserThread file_thread_;
 | 
|    TestingProfile profile_;
 | 
| -  scoped_ptr<NetworkActionPredictor> predictor_;
 | 
| +  scoped_ptr<AutocompleteActionPredictor> predictor_;
 | 
|  };
 | 
|  
 | 
|  
 | 
| -TEST_F(NetworkActionPredictorTest, AddRow) {
 | 
| +TEST_F(AutocompleteActionPredictorTest, AddRow) {
 | 
|    // Add a test entry to the predictor.
 | 
|    std::string guid = AddRow(test_url_db[0]);
 | 
|  
 | 
| @@ -224,7 +228,7 @@ TEST_F(NetworkActionPredictorTest, AddRow) {
 | 
|    EXPECT_EQ(guid, id_it->second);
 | 
|  }
 | 
|  
 | 
| -TEST_F(NetworkActionPredictorTest, UpdateRow) {
 | 
| +TEST_F(AutocompleteActionPredictorTest, UpdateRow) {
 | 
|    ASSERT_NO_FATAL_FAILURE(AddAllRows());
 | 
|  
 | 
|    EXPECT_EQ(arraysize(test_url_db), db_cache()->size());
 | 
| @@ -238,14 +242,14 @@ TEST_F(NetworkActionPredictorTest, UpdateRow) {
 | 
|    DBIdCacheMap::const_iterator id_it = db_id_cache()->find(key);
 | 
|    EXPECT_TRUE(id_it != db_id_cache()->end());
 | 
|  
 | 
| -  NetworkActionPredictorDatabase::Row update_row;
 | 
| +  AutocompleteActionPredictorTable::Row update_row;
 | 
|    update_row.id = id_it->second;
 | 
|    update_row.user_text = key.user_text;
 | 
|    update_row.url = key.url;
 | 
|    update_row.number_of_hits = it->second.number_of_hits + 1;
 | 
|    update_row.number_of_misses = it->second.number_of_misses + 2;
 | 
|  
 | 
| -  UpdateRow(key, update_row);
 | 
| +  UpdateRow(update_row);
 | 
|  
 | 
|    // Get the updated version.
 | 
|    DBCacheMap::const_iterator update_it = db_cache()->find(key);
 | 
| @@ -260,7 +264,7 @@ TEST_F(NetworkActionPredictorTest, UpdateRow) {
 | 
|    EXPECT_EQ(id_it->second, update_id_it->second);
 | 
|  }
 | 
|  
 | 
| -TEST_F(NetworkActionPredictorTest, DeleteAllRows) {
 | 
| +TEST_F(AutocompleteActionPredictorTest, DeleteAllRows) {
 | 
|    ASSERT_NO_FATAL_FAILURE(AddAllRows());
 | 
|  
 | 
|    EXPECT_EQ(arraysize(test_url_db), db_cache()->size());
 | 
| @@ -272,7 +276,7 @@ TEST_F(NetworkActionPredictorTest, DeleteAllRows) {
 | 
|    EXPECT_TRUE(db_id_cache()->empty());
 | 
|  }
 | 
|  
 | 
| -TEST_F(NetworkActionPredictorTest, DeleteRowsWithURLs) {
 | 
| +TEST_F(AutocompleteActionPredictorTest, DeleteRowsWithURLs) {
 | 
|    ASSERT_NO_FATAL_FAILURE(AddAllRows());
 | 
|  
 | 
|    EXPECT_EQ(arraysize(test_url_db), db_cache()->size());
 | 
| @@ -296,9 +300,9 @@ TEST_F(NetworkActionPredictorTest, DeleteRowsWithURLs) {
 | 
|    }
 | 
|  }
 | 
|  
 | 
| -TEST_F(NetworkActionPredictorTest, DeleteOldIdsFromCaches) {
 | 
| -  std::vector<NetworkActionPredictorDatabase::Row::Id> expected;
 | 
| -  std::vector<NetworkActionPredictorDatabase::Row::Id> all_ids;
 | 
| +TEST_F(AutocompleteActionPredictorTest, DeleteOldIdsFromCaches) {
 | 
| +  std::vector<AutocompleteActionPredictorTable::Row::Id> expected;
 | 
| +  std::vector<AutocompleteActionPredictorTable::Row::Id> all_ids;
 | 
|  
 | 
|    for (size_t i = 0; i < arraysize(test_url_db); ++i) {
 | 
|      std::string row_id = AddRow(test_url_db[i]);
 | 
| @@ -313,13 +317,13 @@ TEST_F(NetworkActionPredictorTest, DeleteOldIdsFromCaches) {
 | 
|        ASSERT_TRUE(AddRowToHistory(test_url_db[i]));
 | 
|    }
 | 
|  
 | 
| -  std::vector<NetworkActionPredictorDatabase::Row::Id> id_list;
 | 
| +  std::vector<AutocompleteActionPredictorTable::Row::Id> id_list;
 | 
|    DeleteOldIdsFromCaches(&id_list);
 | 
|    EXPECT_EQ(expected.size(), id_list.size());
 | 
|    EXPECT_EQ(all_ids.size() - expected.size(), db_cache()->size());
 | 
|    EXPECT_EQ(all_ids.size() - expected.size(), db_id_cache()->size());
 | 
|  
 | 
| -  for (std::vector<NetworkActionPredictorDatabase::Row::Id>::iterator it =
 | 
| +  for (std::vector<AutocompleteActionPredictorTable::Row::Id>::iterator it =
 | 
|         all_ids.begin();
 | 
|         it != all_ids.end(); ++it) {
 | 
|      bool in_expected =
 | 
| @@ -330,7 +334,7 @@ TEST_F(NetworkActionPredictorTest, DeleteOldIdsFromCaches) {
 | 
|    }
 | 
|  }
 | 
|  
 | 
| -TEST_F(NetworkActionPredictorTest, RecommendActionURL) {
 | 
| +TEST_F(AutocompleteActionPredictorTest, RecommendActionURL) {
 | 
|    ASSERT_NO_FATAL_FAILURE(AddAllRows());
 | 
|  
 | 
|    AutocompleteMatch match;
 | 
| @@ -344,7 +348,7 @@ TEST_F(NetworkActionPredictorTest, RecommendActionURL) {
 | 
|    }
 | 
|  }
 | 
|  
 | 
| -TEST_F(NetworkActionPredictorTest, RecommendActionSearch) {
 | 
| +TEST_F(AutocompleteActionPredictorTest, RecommendActionSearch) {
 | 
|    ASSERT_NO_FATAL_FAILURE(AddAllRows());
 | 
|  
 | 
|    AutocompleteMatch match;
 | 
| @@ -352,13 +356,15 @@ TEST_F(NetworkActionPredictorTest, RecommendActionSearch) {
 | 
|  
 | 
|    for (size_t i = 0; i < arraysize(test_url_db); ++i) {
 | 
|      match.destination_url = GURL(test_url_db[i].url);
 | 
| -    NetworkActionPredictor::Action expected_action =
 | 
| +    AutocompleteActionPredictor::Action expected_action =
 | 
|          (test_url_db[i].expected_action ==
 | 
| -         NetworkActionPredictor::ACTION_PRERENDER) ?
 | 
| -        NetworkActionPredictor::ACTION_PRECONNECT :
 | 
| +         AutocompleteActionPredictor::ACTION_PRERENDER) ?
 | 
| +        AutocompleteActionPredictor::ACTION_PRECONNECT :
 | 
|          test_url_db[i].expected_action;
 | 
|      EXPECT_EQ(expected_action,
 | 
|                predictor()->RecommendAction(test_url_db[i].user_text, match))
 | 
|          << "Unexpected action for " << match.destination_url;
 | 
|    }
 | 
|  }
 | 
| +
 | 
| +}  // namespace predictors
 | 
| 
 |