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

Side by Side Diff: chrome/browser/history/android/android_history_provider_service.cc

Issue 10217010: Completed the code path from AndroidProviderService to HistoryBackend. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address the comments 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/history/android/android_history_provider_service.h"
6
7 #include "chrome/browser/history/history.h"
8 #include "chrome/browser/profiles/profile.h"
9
10 AndroidHistoryProviderService::AndroidHistoryProviderService(Profile* profile)
11 : profile_(profile) {
12 }
13
14 AndroidHistoryProviderService::~AndroidHistoryProviderService() {
15 }
16
17 void AndroidHistoryProviderService::QueryHistoryAndBookmarks(
18 const std::vector<history::HistoryAndBookmarkRow::ColumnID>& projections,
19 const std::string selection,
20 const std::vector<string16>& selection_args,
21 const std::string sort_order,
22 CancelableRequestConsumerBase* consumer,
23 const QueryCallback& callback) {
24 QueryRequest* request = new QueryRequest(callback);
25 AddRequest(request, consumer);
26 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
27 if (hs) {
28 hs->QueryHistoryAndBookmarks(request, projections, selection,
29 selection_args, sort_order);
30 } else {
31 request->ForwardResultAsync(request->handle(), false, 0);
32 }
33 }
34
35 void AndroidHistoryProviderService::UpdateHistoryAndBookmarks(
36 const history::HistoryAndBookmarkRow& row,
37 const std::string& selection,
38 const std::vector<string16>& selection_args,
39 CancelableRequestConsumerBase* consumer,
40 const UpdateCallback& callback) {
41 UpdateRequest* request = new UpdateRequest(callback);
42 AddRequest(request, consumer);
43 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
44 if (hs)
45 hs->UpdateHistoryAndBookmarks(request, row, selection, selection_args);
46 else
47 request->ForwardResultAsync(request->handle(), false, 0);
48 }
49
50 void AndroidHistoryProviderService::DeleteHistoryAndBookmarks(
51 const std::string& selection,
52 const std::vector<string16>& selection_args,
53 CancelableRequestConsumerBase* consumer,
54 const DeleteCallback& callback) {
55 DeleteRequest* request = new DeleteRequest(callback);
56 AddRequest(request, consumer);
57 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
58 if (hs)
59 hs->DeleteHistoryAndBookmarks(request, selection, selection_args);
60 else
61 request->ForwardResultAsync(request->handle(), false, 0);
62 }
63
64 void AndroidHistoryProviderService::InsertHistoryAndBookmark(
65 const history::HistoryAndBookmarkRow& values,
66 CancelableRequestConsumerBase* consumer,
67 const InsertCallback& callback) {
68 InsertRequest* request = new InsertRequest(callback);
69 AddRequest(request, consumer);
70 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
71 if (hs)
72 hs->InsertHistoryAndBookmark(request, values);
73 else
74 request->ForwardResultAsync(request->handle(), false, 0);
75 }
76
77 void AndroidHistoryProviderService::DeleteHistory(
78 const std::string& selection,
79 const std::vector<string16>& selection_args,
80 CancelableRequestConsumerBase* consumer,
81 const DeleteCallback& callback) {
82 DeleteRequest* request = new DeleteRequest(callback);
83 AddRequest(request, consumer);
84 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
85 if (hs)
86 hs->DeleteHistory(request, selection, selection_args);
87 else
88 request->ForwardResultAsync(request->handle(), false, 0);
89 }
90
91 void AndroidHistoryProviderService::MoveStatement(
92 history::AndroidStatement* statement,
93 int current_pos,
94 int destination,
95 CancelableRequestConsumerBase* consumer,
96 const MoveStatementCallback& callback) {
97 MoveStatementRequest* request = new MoveStatementRequest(callback);
98 AddRequest(request, consumer);
99 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
100 if (hs)
101 hs->MoveStatement(request, statement, current_pos, destination);
102 else
103 request->ForwardResultAsync(request->handle(), current_pos);
104 }
105
106 void AndroidHistoryProviderService::CloseStatement(
107 history::AndroidStatement* statement) {
108 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
109 if (hs)
110 hs->CloseStatement(statement);
111 }
sky 2012/04/27 21:37:22 This leaks if hs is NULL.
michaelbai 2012/04/27 23:26:04 Done.
112
113 void AndroidHistoryProviderService::InsertSearchTerm(
114 const history::SearchRow& row,
115 CancelableRequestConsumerBase* consumer,
116 const InsertCallback& callback) {
117 InsertRequest* request = new InsertRequest(callback);
118 AddRequest(request, consumer);
119 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
120 if (hs)
121 hs->InsertSearchTerm(request, row);
122 else
123 request->ForwardResultAsync(request->handle(), false, 0);
124 }
125
126 void AndroidHistoryProviderService::UpdateSearchTerms(
127 const history::SearchRow& row,
128 const std::string& selection,
129 const std::vector<string16>& selection_args,
130 CancelableRequestConsumerBase* consumer,
131 const UpdateCallback& callback) {
132 UpdateRequest* request = new UpdateRequest(callback);
133 AddRequest(request, consumer);
134 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
135 if (hs)
136 hs->UpdateSearchTerms(request, row, selection, selection_args);
137 else
138 request->ForwardResultAsync(request->handle(), false, 0);
139 }
140
141 void AndroidHistoryProviderService::DeleteSearchTerms(
142 const std::string& selection,
143 const std::vector<string16>& selection_args,
144 CancelableRequestConsumerBase* consumer,
145 const DeleteCallback& callback) {
146 DeleteRequest* request = new DeleteRequest(callback);
147 AddRequest(request, consumer);
148 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
149 if (hs)
150 hs->DeleteSearchTerms(request, selection, selection_args);
151 else
152 request->ForwardResultAsync(request->handle(), false, 0);
153 }
154
155 void AndroidHistoryProviderService::QuerySearchTerms(
156 const std::vector<history::SearchRow::ColumnID>& projections,
157 const std::string selection,
158 const std::vector<string16>& selection_args,
159 const std::string sort_order,
160 CancelableRequestConsumerBase* consumer,
161 const QueryCallback& callback) {
162 QueryRequest* request = new QueryRequest(callback);
163 AddRequest(request, consumer);
164 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
165 if (hs) {
166 hs->QuerySearchTerms(request, projections, selection, selection_args,
167 sort_order);
168 } else {
169 request->ForwardResultAsync(request->handle(), false, 0);
170 }
171 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698