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 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 class AddBookmarkFromAPITask : public HistoryProviderTask { | 735 class AddBookmarkFromAPITask : public HistoryProviderTask { |
736 public: | 736 public: |
737 AddBookmarkFromAPITask(AndroidHistoryProviderService* service, | 737 AddBookmarkFromAPITask(AndroidHistoryProviderService* service, |
738 CancelableRequestConsumer* cancelable_consumer, | 738 CancelableRequestConsumer* cancelable_consumer, |
739 base::CancelableTaskTracker* cancelable_tracker) | 739 base::CancelableTaskTracker* cancelable_tracker) |
740 : HistoryProviderTask(service, cancelable_consumer, cancelable_tracker) {} | 740 : HistoryProviderTask(service, cancelable_consumer, cancelable_tracker) {} |
741 | 741 |
742 history::URLID Run(const history::HistoryAndBookmarkRow& row) { | 742 history::URLID Run(const history::HistoryAndBookmarkRow& row) { |
743 RunAsyncRequestOnUIThreadBlocking( | 743 RunAsyncRequestOnUIThreadBlocking( |
744 base::Bind(&AndroidHistoryProviderService::InsertHistoryAndBookmark, | 744 base::Bind(&AndroidHistoryProviderService::InsertHistoryAndBookmark, |
745 base::Unretained(service()), row, cancelable_consumer(), | 745 base::Unretained(service()), |
| 746 row, |
746 base::Bind(&AddBookmarkFromAPITask::OnBookmarkInserted, | 747 base::Bind(&AddBookmarkFromAPITask::OnBookmarkInserted, |
747 base::Unretained(this)))); | 748 base::Unretained(this)), |
| 749 cancelable_tracker())); |
748 return result_; | 750 return result_; |
749 } | 751 } |
750 | 752 |
751 private: | 753 private: |
752 void OnBookmarkInserted(AndroidHistoryProviderService::Handle handle, | 754 void OnBookmarkInserted(history::URLID id) { |
753 bool succeeded, | 755 // Note that here 0 means an invalid id. |
754 history::URLID id) { | |
755 // Note that here 0 means an invalid id too. | |
756 // This is because it represents a SQLite database row id. | 756 // This is because it represents a SQLite database row id. |
757 result_ = id; | 757 result_ = id; |
758 RequestCompleted(); | 758 RequestCompleted(); |
759 } | 759 } |
760 | 760 |
761 history::URLID result_; | 761 history::URLID result_; |
762 | 762 |
763 DISALLOW_COPY_AND_ASSIGN(AddBookmarkFromAPITask); | 763 DISALLOW_COPY_AND_ASSIGN(AddBookmarkFromAPITask); |
764 }; | 764 }; |
765 | 765 |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 base::Bind(&AddSearchTermFromAPITask::MakeRequestOnUIThread, | 958 base::Bind(&AddSearchTermFromAPITask::MakeRequestOnUIThread, |
959 base::Unretained(this), row)); | 959 base::Unretained(this), row)); |
960 return result_; | 960 return result_; |
961 } | 961 } |
962 | 962 |
963 private: | 963 private: |
964 void MakeRequestOnUIThread(const history::SearchRow& row) { | 964 void MakeRequestOnUIThread(const history::SearchRow& row) { |
965 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 965 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
966 history::SearchRow internal_row = row; | 966 history::SearchRow internal_row = row; |
967 BuildSearchRow(&internal_row); | 967 BuildSearchRow(&internal_row); |
968 service()->InsertSearchTerm(internal_row, cancelable_consumer(), | 968 service()->InsertSearchTerm( |
| 969 internal_row, |
969 base::Bind(&AddSearchTermFromAPITask::OnSearchTermInserted, | 970 base::Bind(&AddSearchTermFromAPITask::OnSearchTermInserted, |
970 base::Unretained(this))); | 971 base::Unretained(this)), |
| 972 cancelable_tracker()); |
971 } | 973 } |
972 | 974 |
973 void OnSearchTermInserted(AndroidHistoryProviderService::Handle handle, | 975 void OnSearchTermInserted(history::URLID id) { |
974 bool succeeded, | 976 // Note that here 0 means an invalid id. |
975 history::URLID id) { | |
976 // Note that here 0 means an invalid id too. | |
977 // This is because it represents a SQLite database row id. | 977 // This is because it represents a SQLite database row id. |
978 result_ = id; | 978 result_ = id; |
979 RequestCompleted(); | 979 RequestCompleted(); |
980 } | 980 } |
981 | 981 |
982 history::URLID result_; | 982 history::URLID result_; |
983 | 983 |
984 DISALLOW_COPY_AND_ASSIGN(AddSearchTermFromAPITask); | 984 DISALLOW_COPY_AND_ASSIGN(AddSearchTermFromAPITask); |
985 }; | 985 }; |
986 | 986 |
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1677 Java_ChromeBrowserProvider_onBookmarkChanged(env, obj.obj()); | 1677 Java_ChromeBrowserProvider_onBookmarkChanged(env, obj.obj()); |
1678 } else if (type == | 1678 } else if (type == |
1679 chrome::NOTIFICATION_HISTORY_KEYWORD_SEARCH_TERM_UPDATED) { | 1679 chrome::NOTIFICATION_HISTORY_KEYWORD_SEARCH_TERM_UPDATED) { |
1680 JNIEnv* env = AttachCurrentThread(); | 1680 JNIEnv* env = AttachCurrentThread(); |
1681 ScopedJavaLocalRef<jobject> obj = weak_java_provider_.get(env); | 1681 ScopedJavaLocalRef<jobject> obj = weak_java_provider_.get(env); |
1682 if (obj.is_null()) | 1682 if (obj.is_null()) |
1683 return; | 1683 return; |
1684 Java_ChromeBrowserProvider_onSearchTermChanged(env, obj.obj()); | 1684 Java_ChromeBrowserProvider_onSearchTermChanged(env, obj.obj()); |
1685 } | 1685 } |
1686 } | 1686 } |
OLD | NEW |