| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/browser/history/history_backend.h" | 5 #include "chrome/browser/history/history_backend.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1057 return; | 1057 return; |
| 1058 | 1058 |
| 1059 if (db_.get()) { | 1059 if (db_.get()) { |
| 1060 db_->QuerySegmentUsage(from_time, max_result_count, &request->value.get()); | 1060 db_->QuerySegmentUsage(from_time, max_result_count, &request->value.get()); |
| 1061 | 1061 |
| 1062 // If this is the first time we query segments, invoke | 1062 // If this is the first time we query segments, invoke |
| 1063 // DeleteOldSegmentData asynchronously. We do this to cleanup old | 1063 // DeleteOldSegmentData asynchronously. We do this to cleanup old |
| 1064 // entries. | 1064 // entries. |
| 1065 if (!segment_queried_) { | 1065 if (!segment_queried_) { |
| 1066 segment_queried_ = true; | 1066 segment_queried_ = true; |
| 1067 MessageLoop::current()->PostTask(FROM_HERE, | 1067 MessageLoop::current()->PostTask( |
| 1068 NewRunnableMethod(this, &HistoryBackend::DeleteOldSegmentData)); | 1068 FROM_HERE, |
| 1069 base::Bind(&HistoryBackend::DeleteOldSegmentData, this)); |
| 1069 } | 1070 } |
| 1070 } | 1071 } |
| 1071 request->ForwardResult(request->handle(), &request->value.get()); | 1072 request->ForwardResult(request->handle(), &request->value.get()); |
| 1072 } | 1073 } |
| 1073 | 1074 |
| 1074 // Keyword visits -------------------------------------------------------------- | 1075 // Keyword visits -------------------------------------------------------------- |
| 1075 | 1076 |
| 1076 void HistoryBackend::SetKeywordSearchTermsForURL(const GURL& url, | 1077 void HistoryBackend::SetKeywordSearchTermsForURL(const GURL& url, |
| 1077 TemplateURLID keyword_id, | 1078 TemplateURLID keyword_id, |
| 1078 const string16& term) { | 1079 const string16& term) { |
| (...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1927 if (text_database_.get()) { | 1928 if (text_database_.get()) { |
| 1928 text_database_->CommitTransaction(); | 1929 text_database_->CommitTransaction(); |
| 1929 text_database_->BeginTransaction(); | 1930 text_database_->BeginTransaction(); |
| 1930 } | 1931 } |
| 1931 } | 1932 } |
| 1932 | 1933 |
| 1933 void HistoryBackend::ScheduleCommit() { | 1934 void HistoryBackend::ScheduleCommit() { |
| 1934 if (scheduled_commit_.get()) | 1935 if (scheduled_commit_.get()) |
| 1935 return; | 1936 return; |
| 1936 scheduled_commit_ = new CommitLaterTask(this); | 1937 scheduled_commit_ = new CommitLaterTask(this); |
| 1937 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 1938 MessageLoop::current()->PostDelayedTask( |
| 1938 NewRunnableMethod(scheduled_commit_.get(), | 1939 FROM_HERE, |
| 1939 &CommitLaterTask::RunCommit), | 1940 base::Bind(&CommitLaterTask::RunCommit, scheduled_commit_.get()), |
| 1940 kCommitIntervalMs); | 1941 kCommitIntervalMs); |
| 1941 } | 1942 } |
| 1942 | 1943 |
| 1943 void HistoryBackend::CancelScheduledCommit() { | 1944 void HistoryBackend::CancelScheduledCommit() { |
| 1944 if (scheduled_commit_) { | 1945 if (scheduled_commit_) { |
| 1945 scheduled_commit_->Cancel(); | 1946 scheduled_commit_->Cancel(); |
| 1946 scheduled_commit_ = NULL; | 1947 scheduled_commit_ = NULL; |
| 1947 } | 1948 } |
| 1948 } | 1949 } |
| 1949 | 1950 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1967 db_task_requests_.pop_front(); | 1968 db_task_requests_.pop_front(); |
| 1968 if (request->value->RunOnDBThread(this, db_.get())) { | 1969 if (request->value->RunOnDBThread(this, db_.get())) { |
| 1969 // The task is done. Notify the callback. | 1970 // The task is done. Notify the callback. |
| 1970 request->ForwardResult(); | 1971 request->ForwardResult(); |
| 1971 // We AddRef'd the request before adding, need to release it now. | 1972 // We AddRef'd the request before adding, need to release it now. |
| 1972 request->Release(); | 1973 request->Release(); |
| 1973 } else { | 1974 } else { |
| 1974 // Tasks wants to run some more. Schedule it at the end of current tasks. | 1975 // Tasks wants to run some more. Schedule it at the end of current tasks. |
| 1975 db_task_requests_.push_back(request); | 1976 db_task_requests_.push_back(request); |
| 1976 // And process it after an invoke later. | 1977 // And process it after an invoke later. |
| 1977 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( | 1978 MessageLoop::current()->PostTask( |
| 1978 this, &HistoryBackend::ProcessDBTaskImpl)); | 1979 FROM_HERE, base::Bind(&HistoryBackend::ProcessDBTaskImpl, this)); |
| 1979 } | 1980 } |
| 1980 } | 1981 } |
| 1981 | 1982 |
| 1982 void HistoryBackend::ReleaseDBTasks() { | 1983 void HistoryBackend::ReleaseDBTasks() { |
| 1983 for (std::list<HistoryDBTaskRequest*>::iterator i = | 1984 for (std::list<HistoryDBTaskRequest*>::iterator i = |
| 1984 db_task_requests_.begin(); i != db_task_requests_.end(); ++i) { | 1985 db_task_requests_.begin(); i != db_task_requests_.end(); ++i) { |
| 1985 (*i)->Release(); | 1986 (*i)->Release(); |
| 1986 } | 1987 } |
| 1987 db_task_requests_.clear(); | 1988 db_task_requests_.clear(); |
| 1988 } | 1989 } |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2311 break; | 2312 break; |
| 2312 } | 2313 } |
| 2313 } | 2314 } |
| 2314 } | 2315 } |
| 2315 UMA_HISTOGRAM_TIMES("History.GetFavIconFromDB", // historical name | 2316 UMA_HISTOGRAM_TIMES("History.GetFavIconFromDB", // historical name |
| 2316 TimeTicks::Now() - beginning_time); | 2317 TimeTicks::Now() - beginning_time); |
| 2317 return success; | 2318 return success; |
| 2318 } | 2319 } |
| 2319 | 2320 |
| 2320 } // namespace history | 2321 } // namespace history |
| OLD | NEW |