| 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 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 RemoveBookmarksFromAPITask(AndroidHistoryProviderService* service, | 844 RemoveBookmarksFromAPITask(AndroidHistoryProviderService* service, |
| 845 CancelableRequestConsumer* cancelable_consumer, | 845 CancelableRequestConsumer* cancelable_consumer, |
| 846 base::CancelableTaskTracker* cancelable_tracker) | 846 base::CancelableTaskTracker* cancelable_tracker) |
| 847 : HistoryProviderTask(service, cancelable_consumer, cancelable_tracker), | 847 : HistoryProviderTask(service, cancelable_consumer, cancelable_tracker), |
| 848 result_(0) {} | 848 result_(0) {} |
| 849 | 849 |
| 850 int Run(const std::string& selection, | 850 int Run(const std::string& selection, |
| 851 const std::vector<base::string16>& selection_args) { | 851 const std::vector<base::string16>& selection_args) { |
| 852 RunAsyncRequestOnUIThreadBlocking( | 852 RunAsyncRequestOnUIThreadBlocking( |
| 853 base::Bind(&AndroidHistoryProviderService::DeleteHistoryAndBookmarks, | 853 base::Bind(&AndroidHistoryProviderService::DeleteHistoryAndBookmarks, |
| 854 base::Unretained(service()), selection, selection_args, | 854 base::Unretained(service()), |
| 855 cancelable_consumer(), | 855 selection, |
| 856 selection_args, |
| 856 base::Bind(&RemoveBookmarksFromAPITask::OnBookmarksRemoved, | 857 base::Bind(&RemoveBookmarksFromAPITask::OnBookmarksRemoved, |
| 857 base::Unretained(this)))); | 858 base::Unretained(this)), |
| 859 cancelable_tracker())); |
| 858 return result_; | 860 return result_; |
| 859 } | 861 } |
| 860 | 862 |
| 861 private: | 863 private: |
| 862 void OnBookmarksRemoved(AndroidHistoryProviderService::Handle handle, | 864 void OnBookmarksRemoved(int removed_row_count) { |
| 863 bool succeeded, | |
| 864 int removed_row_count) { | |
| 865 result_ = removed_row_count; | 865 result_ = removed_row_count; |
| 866 RequestCompleted(); | 866 RequestCompleted(); |
| 867 } | 867 } |
| 868 | 868 |
| 869 int result_; | 869 int result_; |
| 870 | 870 |
| 871 DISALLOW_COPY_AND_ASSIGN(RemoveBookmarksFromAPITask); | 871 DISALLOW_COPY_AND_ASSIGN(RemoveBookmarksFromAPITask); |
| 872 }; | 872 }; |
| 873 | 873 |
| 874 // Removes history from the API. | 874 // Removes history from the API. |
| 875 class RemoveHistoryFromAPITask : public HistoryProviderTask { | 875 class RemoveHistoryFromAPITask : public HistoryProviderTask { |
| 876 public: | 876 public: |
| 877 RemoveHistoryFromAPITask(AndroidHistoryProviderService* service, | 877 RemoveHistoryFromAPITask(AndroidHistoryProviderService* service, |
| 878 CancelableRequestConsumer* cancelable_consumer, | 878 CancelableRequestConsumer* cancelable_consumer, |
| 879 base::CancelableTaskTracker* cancelable_tracker) | 879 base::CancelableTaskTracker* cancelable_tracker) |
| 880 : HistoryProviderTask(service, cancelable_consumer, cancelable_tracker), | 880 : HistoryProviderTask(service, cancelable_consumer, cancelable_tracker), |
| 881 result_(0) {} | 881 result_(0) {} |
| 882 | 882 |
| 883 int Run(const std::string& selection, | 883 int Run(const std::string& selection, |
| 884 const std::vector<base::string16>& selection_args) { | 884 const std::vector<base::string16>& selection_args) { |
| 885 RunAsyncRequestOnUIThreadBlocking( | 885 RunAsyncRequestOnUIThreadBlocking( |
| 886 base::Bind(&AndroidHistoryProviderService::DeleteHistory, | 886 base::Bind(&AndroidHistoryProviderService::DeleteHistory, |
| 887 base::Unretained(service()), selection, | 887 base::Unretained(service()), |
| 888 selection_args, cancelable_consumer(), | 888 selection, |
| 889 selection_args, |
| 889 base::Bind(&RemoveHistoryFromAPITask::OnHistoryRemoved, | 890 base::Bind(&RemoveHistoryFromAPITask::OnHistoryRemoved, |
| 890 base::Unretained(this)))); | 891 base::Unretained(this)), |
| 892 cancelable_tracker())); |
| 891 return result_; | 893 return result_; |
| 892 } | 894 } |
| 893 | 895 |
| 894 private: | 896 private: |
| 895 void OnHistoryRemoved(AndroidHistoryProviderService::Handle handle, | 897 void OnHistoryRemoved(int removed_row_count) { |
| 896 bool succeeded, | |
| 897 int removed_row_count) { | |
| 898 result_ = removed_row_count; | 898 result_ = removed_row_count; |
| 899 RequestCompleted(); | 899 RequestCompleted(); |
| 900 } | 900 } |
| 901 | 901 |
| 902 int result_; | 902 int result_; |
| 903 | 903 |
| 904 DISALLOW_COPY_AND_ASSIGN(RemoveHistoryFromAPITask); | 904 DISALLOW_COPY_AND_ASSIGN(RemoveHistoryFromAPITask); |
| 905 }; | 905 }; |
| 906 | 906 |
| 907 // This class provides the common method for the SearchTermAPIHelper. | 907 // This class provides the common method for the SearchTermAPIHelper. |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1087 base::CancelableTaskTracker* cancelable_tracker, | 1087 base::CancelableTaskTracker* cancelable_tracker, |
| 1088 Profile* profile) | 1088 Profile* profile) |
| 1089 : SearchTermTask(service, | 1089 : SearchTermTask(service, |
| 1090 cancelable_consumer, | 1090 cancelable_consumer, |
| 1091 cancelable_tracker, | 1091 cancelable_tracker, |
| 1092 profile), | 1092 profile), |
| 1093 result_() {} | 1093 result_() {} |
| 1094 | 1094 |
| 1095 int Run(const std::string& selection, | 1095 int Run(const std::string& selection, |
| 1096 const std::vector<base::string16>& selection_args) { | 1096 const std::vector<base::string16>& selection_args) { |
| 1097 RunAsyncRequestOnUIThreadBlocking( | 1097 RunAsyncRequestOnUIThreadBlocking(base::Bind( |
| 1098 base::Bind(&AndroidHistoryProviderService::DeleteSearchTerms, | 1098 &AndroidHistoryProviderService::DeleteSearchTerms, |
| 1099 base::Unretained(service()), selection, selection_args, | 1099 base::Unretained(service()), |
| 1100 cancelable_consumer(), | 1100 selection, |
| 1101 base::Bind( | 1101 selection_args, |
| 1102 &RemoveSearchTermsFromAPITask::OnSearchTermsDeleted, | 1102 base::Bind(&RemoveSearchTermsFromAPITask::OnSearchTermsDeleted, |
| 1103 base::Unretained(this)))); | 1103 base::Unretained(this)), |
| 1104 cancelable_tracker())); |
| 1104 return result_; | 1105 return result_; |
| 1105 } | 1106 } |
| 1106 | 1107 |
| 1107 private: | 1108 private: |
| 1108 void OnSearchTermsDeleted(AndroidHistoryProviderService::Handle handle, | 1109 void OnSearchTermsDeleted(int deleted_row_count) { |
| 1109 bool succeeded, | |
| 1110 int deleted_row_count) { | |
| 1111 result_ = deleted_row_count; | 1110 result_ = deleted_row_count; |
| 1112 RequestCompleted(); | 1111 RequestCompleted(); |
| 1113 } | 1112 } |
| 1114 | 1113 |
| 1115 int result_; | 1114 int result_; |
| 1116 | 1115 |
| 1117 DISALLOW_COPY_AND_ASSIGN(RemoveSearchTermsFromAPITask); | 1116 DISALLOW_COPY_AND_ASSIGN(RemoveSearchTermsFromAPITask); |
| 1118 }; | 1117 }; |
| 1119 | 1118 |
| 1120 // ------------- Other utility methods (may use tasks) ------------- // | 1119 // ------------- Other utility methods (may use tasks) ------------- // |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1677 Java_ChromeBrowserProvider_onBookmarkChanged(env, obj.obj()); | 1676 Java_ChromeBrowserProvider_onBookmarkChanged(env, obj.obj()); |
| 1678 } else if (type == | 1677 } else if (type == |
| 1679 chrome::NOTIFICATION_HISTORY_KEYWORD_SEARCH_TERM_UPDATED) { | 1678 chrome::NOTIFICATION_HISTORY_KEYWORD_SEARCH_TERM_UPDATED) { |
| 1680 JNIEnv* env = AttachCurrentThread(); | 1679 JNIEnv* env = AttachCurrentThread(); |
| 1681 ScopedJavaLocalRef<jobject> obj = weak_java_provider_.get(env); | 1680 ScopedJavaLocalRef<jobject> obj = weak_java_provider_.get(env); |
| 1682 if (obj.is_null()) | 1681 if (obj.is_null()) |
| 1683 return; | 1682 return; |
| 1684 Java_ChromeBrowserProvider_onSearchTermChanged(env, obj.obj()); | 1683 Java_ChromeBrowserProvider_onSearchTermChanged(env, obj.obj()); |
| 1685 } | 1684 } |
| 1686 } | 1685 } |
| OLD | NEW |