| 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 #include "chrome/browser/android/provider/chrome_browser_provider.h" | 5 #include "chrome/browser/android/provider/chrome_browser_provider.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <list> | 8 #include <list> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 : HistoryProviderTask(service, cancelable_consumer, cancelable_tracker), | 774 : HistoryProviderTask(service, cancelable_consumer, cancelable_tracker), |
| 775 result_(NULL) {} | 775 result_(NULL) {} |
| 776 | 776 |
| 777 history::AndroidStatement* Run( | 777 history::AndroidStatement* Run( |
| 778 const std::vector<history::HistoryAndBookmarkRow::ColumnID>& projections, | 778 const std::vector<history::HistoryAndBookmarkRow::ColumnID>& projections, |
| 779 const std::string& selection, | 779 const std::string& selection, |
| 780 const std::vector<base::string16>& selection_args, | 780 const std::vector<base::string16>& selection_args, |
| 781 const std::string& sort_order) { | 781 const std::string& sort_order) { |
| 782 RunAsyncRequestOnUIThreadBlocking( | 782 RunAsyncRequestOnUIThreadBlocking( |
| 783 base::Bind(&AndroidHistoryProviderService::QueryHistoryAndBookmarks, | 783 base::Bind(&AndroidHistoryProviderService::QueryHistoryAndBookmarks, |
| 784 base::Unretained(service()), projections, selection, | 784 base::Unretained(service()), |
| 785 selection_args, sort_order, cancelable_consumer(), | 785 projections, |
| 786 selection, |
| 787 selection_args, |
| 788 sort_order, |
| 786 base::Bind(&QueryBookmarksFromAPITask::OnBookmarksQueried, | 789 base::Bind(&QueryBookmarksFromAPITask::OnBookmarksQueried, |
| 787 base::Unretained(this)))); | 790 base::Unretained(this)), |
| 791 cancelable_tracker())); |
| 788 return result_; | 792 return result_; |
| 789 } | 793 } |
| 790 | 794 |
| 791 private: | 795 private: |
| 792 void OnBookmarksQueried(AndroidHistoryProviderService::Handle handle, | 796 void OnBookmarksQueried(history::AndroidStatement* statement) { |
| 793 bool succeeded, | |
| 794 history::AndroidStatement* statement) { | |
| 795 result_ = statement; | 797 result_ = statement; |
| 796 RequestCompleted(); | 798 RequestCompleted(); |
| 797 } | 799 } |
| 798 | 800 |
| 799 history::AndroidStatement* result_; | 801 history::AndroidStatement* result_; |
| 800 | 802 |
| 801 DISALLOW_COPY_AND_ASSIGN(QueryBookmarksFromAPITask); | 803 DISALLOW_COPY_AND_ASSIGN(QueryBookmarksFromAPITask); |
| 802 }; | 804 }; |
| 803 | 805 |
| 804 // Updates bookmarks from the API. | 806 // Updates bookmarks from the API. |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 995 cancelable_consumer, | 997 cancelable_consumer, |
| 996 cancelable_tracker, | 998 cancelable_tracker, |
| 997 profile), | 999 profile), |
| 998 result_(NULL) {} | 1000 result_(NULL) {} |
| 999 | 1001 |
| 1000 history::AndroidStatement* Run( | 1002 history::AndroidStatement* Run( |
| 1001 const std::vector<history::SearchRow::ColumnID>& projections, | 1003 const std::vector<history::SearchRow::ColumnID>& projections, |
| 1002 const std::string& selection, | 1004 const std::string& selection, |
| 1003 const std::vector<base::string16>& selection_args, | 1005 const std::vector<base::string16>& selection_args, |
| 1004 const std::string& sort_order) { | 1006 const std::string& sort_order) { |
| 1005 RunAsyncRequestOnUIThreadBlocking( | 1007 RunAsyncRequestOnUIThreadBlocking(base::Bind( |
| 1006 base::Bind(&AndroidHistoryProviderService::QuerySearchTerms, | 1008 &AndroidHistoryProviderService::QuerySearchTerms, |
| 1007 base::Unretained(service()), projections, selection, | 1009 base::Unretained(service()), |
| 1008 selection_args, sort_order, cancelable_consumer(), | 1010 projections, |
| 1009 base::Bind( | 1011 selection, |
| 1010 &QuerySearchTermsFromAPITask::OnSearchTermsQueried, | 1012 selection_args, |
| 1011 base::Unretained(this)))); | 1013 sort_order, |
| 1014 base::Bind(&QuerySearchTermsFromAPITask::OnSearchTermsQueried, |
| 1015 base::Unretained(this)), |
| 1016 cancelable_tracker())); |
| 1012 return result_; | 1017 return result_; |
| 1013 } | 1018 } |
| 1014 | 1019 |
| 1015 private: | 1020 private: |
| 1016 // Callback to return the result. | 1021 // Callback to return the result. |
| 1017 void OnSearchTermsQueried(AndroidHistoryProviderService::Handle handle, | 1022 void OnSearchTermsQueried(history::AndroidStatement* statement) { |
| 1018 bool succeeded, | |
| 1019 history::AndroidStatement* statement) { | |
| 1020 result_ = statement; | 1023 result_ = statement; |
| 1021 RequestCompleted(); | 1024 RequestCompleted(); |
| 1022 } | 1025 } |
| 1023 | 1026 |
| 1024 history::AndroidStatement* result_; | 1027 history::AndroidStatement* result_; |
| 1025 | 1028 |
| 1026 DISALLOW_COPY_AND_ASSIGN(QuerySearchTermsFromAPITask); | 1029 DISALLOW_COPY_AND_ASSIGN(QuerySearchTermsFromAPITask); |
| 1027 }; | 1030 }; |
| 1028 | 1031 |
| 1029 // Updates search terms from the API. | 1032 // Updates search terms from the API. |
| (...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1676 Java_ChromeBrowserProvider_onBookmarkChanged(env, obj.obj()); | 1679 Java_ChromeBrowserProvider_onBookmarkChanged(env, obj.obj()); |
| 1677 } else if (type == | 1680 } else if (type == |
| 1678 chrome::NOTIFICATION_HISTORY_KEYWORD_SEARCH_TERM_UPDATED) { | 1681 chrome::NOTIFICATION_HISTORY_KEYWORD_SEARCH_TERM_UPDATED) { |
| 1679 JNIEnv* env = AttachCurrentThread(); | 1682 JNIEnv* env = AttachCurrentThread(); |
| 1680 ScopedJavaLocalRef<jobject> obj = weak_java_provider_.get(env); | 1683 ScopedJavaLocalRef<jobject> obj = weak_java_provider_.get(env); |
| 1681 if (obj.is_null()) | 1684 if (obj.is_null()) |
| 1682 return; | 1685 return; |
| 1683 Java_ChromeBrowserProvider_onSearchTermChanged(env, obj.obj()); | 1686 Java_ChromeBrowserProvider_onSearchTermChanged(env, obj.obj()); |
| 1684 } | 1687 } |
| 1685 } | 1688 } |
| OLD | NEW |