OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ | 5 #ifndef CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ |
6 #define CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ | 6 #define CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/containers/mru_cache.h" | 13 #include "base/containers/mru_cache.h" |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
16 #include "base/memory/memory_pressure_listener.h" | 16 #include "base/memory/memory_pressure_listener.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/observer_list.h" | 18 #include "base/observer_list.h" |
19 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
20 #include "base/task/cancelable_task_tracker.h" | 20 #include "base/task/cancelable_task_tracker.h" |
21 #include "components/favicon_base/favicon_usage_data.h" | 21 #include "components/favicon_base/favicon_usage_data.h" |
22 #include "components/history/core/browser/expire_history_backend.h" | 22 #include "components/history/core/browser/expire_history_backend.h" |
23 #include "components/history/core/browser/history_backend_notifier.h" | 23 #include "components/history/core/browser/history_backend_notifier.h" |
24 #include "components/history/core/browser/history_types.h" | 24 #include "components/history/core/browser/history_types.h" |
25 #include "components/history/core/browser/keyword_id.h" | 25 #include "components/history/core/browser/keyword_id.h" |
26 #include "components/history/core/browser/thumbnail_database.h" | 26 #include "components/history/core/browser/thumbnail_database.h" |
27 #include "components/history/core/browser/visit_tracker.h" | 27 #include "components/history/core/browser/visit_tracker.h" |
28 #include "sql/init_status.h" | 28 #include "sql/init_status.h" |
29 | 29 |
30 #if defined(OS_ANDROID) | |
31 #include "components/history/core/browser/android/android_history_types.h" | |
32 #endif | |
33 | |
34 class HistoryURLProvider; | 30 class HistoryURLProvider; |
35 struct HistoryURLProviderParams; | 31 struct HistoryURLProviderParams; |
36 class SkBitmap; | 32 class SkBitmap; |
37 class TestingProfile; | 33 class TestingProfile; |
38 struct ThumbnailScore; | 34 struct ThumbnailScore; |
39 | 35 |
40 namespace base { | 36 namespace base { |
41 class MessageLoop; | 37 class MessageLoop; |
42 class SingleThreadTaskRunner; | 38 class SingleThreadTaskRunner; |
43 } | 39 } |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 const base::string16& term); | 325 const base::string16& term); |
330 | 326 |
331 // Observers ----------------------------------------------------------------- | 327 // Observers ----------------------------------------------------------------- |
332 | 328 |
333 void AddObserver(HistoryBackendObserver* observer); | 329 void AddObserver(HistoryBackendObserver* observer); |
334 void RemoveObserver(HistoryBackendObserver* observer); | 330 void RemoveObserver(HistoryBackendObserver* observer); |
335 | 331 |
336 #if defined(OS_ANDROID) | 332 #if defined(OS_ANDROID) |
337 // Android Provider --------------------------------------------------------- | 333 // Android Provider --------------------------------------------------------- |
338 | 334 |
339 // History and bookmarks ---------------------------------------------------- | 335 // Returns the android provider backend associated with the HistoryBackend. |
340 // Inserts the given values into history backend. | 336 AndroidProviderBackend* android_provider_backend() { |
341 AndroidURLID InsertHistoryAndBookmark(const HistoryAndBookmarkRow& row); | 337 return android_provider_backend_.get(); |
342 | 338 } |
343 // Runs the given query on history backend and returns the result. | 339 #endif |
344 // | |
345 // |projections| is the vector of the result columns. | |
346 // |selection| is the SQL WHERE clause without 'WHERE'. | |
347 // |selection_args| is the arguments for WHERE clause. | |
348 // |sort_order| is the SQL ORDER clause. | |
349 history::AndroidStatement* QueryHistoryAndBookmarks( | |
350 const std::vector<HistoryAndBookmarkRow::ColumnID>& projections, | |
351 const std::string& selection, | |
352 const std::vector<base::string16>& selection_args, | |
353 const std::string& sort_order); | |
354 | |
355 // Returns the number of row updated by the update query. | |
356 // | |
357 // |row| is the value to update. | |
358 // |selection| is the SQL WHERE clause without 'WHERE'. | |
359 // |selection_args| is the arguments for the WHERE clause. | |
360 int UpdateHistoryAndBookmarks( | |
361 const HistoryAndBookmarkRow& row, | |
362 const std::string& selection, | |
363 const std::vector<base::string16>& selection_args); | |
364 | |
365 // Deletes the specified rows and returns the number of rows deleted. | |
366 // | |
367 // |selection| is the SQL WHERE clause without 'WHERE'. | |
368 // |selection_args| is the arguments for the WHERE clause. | |
369 // | |
370 // If |selection| is empty all history and bookmarks are deleted. | |
371 int DeleteHistoryAndBookmarks( | |
372 const std::string& selection, | |
373 const std::vector<base::string16>& selection_args); | |
374 | |
375 // Deletes the matched history and returns the number of rows deleted. | |
376 int DeleteHistory(const std::string& selection, | |
377 const std::vector<base::string16>& selection_args); | |
378 | |
379 // Statement ---------------------------------------------------------------- | |
380 // Move the statement's current position. | |
381 int MoveStatement(history::AndroidStatement* statement, | |
382 int current_pos, | |
383 int destination); | |
384 | |
385 // Close the given statement. The ownership is transfered. | |
386 void CloseStatement(AndroidStatement* statement); | |
387 | |
388 // Search terms ------------------------------------------------------------- | |
389 // Inserts the given values and returns the SearchTermID of the inserted row. | |
390 SearchTermID InsertSearchTerm(const SearchRow& row); | |
391 | |
392 // Returns the number of row updated by the update query. | |
393 // | |
394 // |row| is the value to update. | |
395 // |selection| is the SQL WHERE clause without 'WHERE'. | |
396 // |selection_args| is the arguments for the WHERE clause. | |
397 int UpdateSearchTerms(const SearchRow& row, | |
398 const std::string& selection, | |
399 const std::vector<base::string16> selection_args); | |
400 | |
401 // Deletes the matched rows and returns the number of deleted rows. | |
402 // | |
403 // |selection| is the SQL WHERE clause without 'WHERE'. | |
404 // |selection_args| is the arguments for WHERE clause. | |
405 // | |
406 // If |selection| is empty all search terms will be deleted. | |
407 int DeleteSearchTerms(const std::string& selection, | |
408 const std::vector<base::string16> selection_args); | |
409 | |
410 // Returns the result of the given query. | |
411 // | |
412 // |projections| specifies the result columns. | |
413 // |selection| is the SQL WHERE clause without 'WHERE'. | |
414 // |selection_args| is the arguments for WHERE clause. | |
415 // |sort_order| is the SQL ORDER clause. | |
416 history::AndroidStatement* QuerySearchTerms( | |
417 const std::vector<SearchRow::ColumnID>& projections, | |
418 const std::string& selection, | |
419 const std::vector<base::string16>& selection_args, | |
420 const std::string& sort_order); | |
421 | |
422 #endif // defined(OS_ANDROID) | |
423 | 340 |
424 // Generic operations -------------------------------------------------------- | 341 // Generic operations -------------------------------------------------------- |
425 | 342 |
426 void ProcessDBTask( | 343 void ProcessDBTask( |
427 scoped_ptr<HistoryDBTask> task, | 344 scoped_ptr<HistoryDBTask> task, |
428 scoped_refptr<base::SingleThreadTaskRunner> origin_loop, | 345 scoped_refptr<base::SingleThreadTaskRunner> origin_loop, |
429 const base::CancelableTaskTracker::IsCanceledCallback& is_canceled); | 346 const base::CancelableTaskTracker::IsCanceledCallback& is_canceled); |
430 | 347 |
431 virtual bool GetAllTypedURLs(URLRows* urls); | 348 virtual bool GetAllTypedURLs(URLRows* urls); |
432 | 349 |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 | 834 |
918 // List of observers | 835 // List of observers |
919 ObserverList<HistoryBackendObserver> observers_; | 836 ObserverList<HistoryBackendObserver> observers_; |
920 | 837 |
921 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); | 838 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); |
922 }; | 839 }; |
923 | 840 |
924 } // namespace history | 841 } // namespace history |
925 | 842 |
926 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ | 843 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ |
OLD | NEW |