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