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