Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(528)

Unified Diff: chrome/browser/predictors/autocomplete_action_predictor_database.h

Issue 10380041: Refactoring AutocompleteActionPredictor Database. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Syncing to HEAD Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/predictors/autocomplete_action_predictor_database.h
diff --git a/chrome/browser/predictors/autocomplete_action_predictor_database.h b/chrome/browser/predictors/autocomplete_action_predictor_database.h
deleted file mode 100644
index 38783f29c93c8b439cb8faffd761d7bcfdaffef5..0000000000000000000000000000000000000000
--- a/chrome/browser/predictors/autocomplete_action_predictor_database.h
+++ /dev/null
@@ -1,105 +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_PREDICTORS_AUTOCOMPLETE_ACTION_PREDICTOR_DATABASE_H_
-#define CHROME_BROWSER_PREDICTORS_AUTOCOMPLETE_ACTION_PREDICTOR_DATABASE_H_
-#pragma once
-
-#include <ostream>
-#include <string>
-#include <vector>
-
-#include "base/file_path.h"
-#include "base/gtest_prod_util.h"
-#include "base/memory/ref_counted.h"
-#include "base/string16.h"
-#include "base/synchronization/cancellation_flag.h"
-#include "googleurl/src/gurl.h"
-#include "sql/connection.h"
-
-class Profile;
-
-// This manages the autocomplete action predictor table within the SQLite
-// database passed in to the constructor. It expects the following scheme:
-//
-// network_action_predictor
-// id A unique id.
-// user_text What the user typed.
-// url The URL of the entry.
-// number_of_hits Number of times the entry was shown to the user and
-// selected.
-// number_of_misses Number of times the entry was shown to the user but not
-// selected.
-//
-// Ref-counted as it is created and destroyed on a different thread to the DB
-// thread that is required for all methods performing database access.
-class AutocompleteActionPredictorDatabase
- : public base::RefCountedThreadSafe<AutocompleteActionPredictorDatabase> {
- public:
- struct Row {
- // TODO(dominich): Make this 64-bit integer as an optimization. This
- // requires some investigation into how to make sure the id is unique for
- // each user_text/url pair.
- // http://crbug.com/102020
- typedef std::string Id;
-
- Row();
-
- // Only used by unit tests.
- Row(const Id& id,
- const string16& user_text,
- const GURL& url,
- int number_of_hits,
- int number_of_misses);
-
- Id id;
- string16 user_text;
- GURL url;
- int number_of_hits;
- int number_of_misses;
- };
-
- explicit AutocompleteActionPredictorDatabase(Profile* profile);
-
- // Opens the database file from the profile path. Separated from the
- // constructor to ease construction/destruction of this object on one thread
- // but database access on the DB thread.
- void Initialize();
-
- void GetRow(const Row::Id& id, Row* row);
- void GetAllRows(std::vector<Row>* row_buffer);
-
- void AddRow(const Row& row);
- void UpdateRow(const Row& row);
- void DeleteRow(const Row::Id& id);
- void DeleteRows(const std::vector<Row::Id>& id_list);
- void DeleteAllRows();
-
- // For batching database operations.
- void BeginTransaction();
- void CommitTransaction();
-
- void OnPredictorDestroyed();
-
- private:
- friend class AutocompleteActionPredictorDatabaseTest;
- friend class base::RefCountedThreadSafe<AutocompleteActionPredictorDatabase>;
- virtual ~AutocompleteActionPredictorDatabase();
-
- void CreateTable();
-
- // TODO(dominich): Consider adding this table to one of the history databases.
- // In memory is currently used, but adding to the on-disk visits database
- // would allow DeleteOldEntries to be cheaper through use of a join.
- FilePath db_path_;
- sql::Connection db_;
-
- // Set when the AutocompleteActionPredictor is destroyed so we can cancel any
- // posted database requests.
- base::CancellationFlag canceled_;
-
- DISALLOW_COPY_AND_ASSIGN(AutocompleteActionPredictorDatabase);
-};
-
-#endif // CHROME_BROWSER_PREDICTORS_AUTOCOMPLETE_ACTION_PREDICTOR_DATABASE_H_

Powered by Google App Engine
This is Rietveld 408576698