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/history/android/sqlite_cursor.h" | 5 #include "chrome/browser/history/android/sqlite_cursor.h" |
6 | 6 |
7 #include <jni.h> | 7 #include <jni.h> |
8 | 8 |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 73 |
74 void TearDown() override { | 74 void TearDown() override { |
75 testing_profile_->DestroyHistoryService(); | 75 testing_profile_->DestroyHistoryService(); |
76 profile_manager_.DeleteTestingProfile(chrome::kInitialProfile); | 76 profile_manager_.DeleteTestingProfile(chrome::kInitialProfile); |
77 testing_profile_ = NULL; | 77 testing_profile_ = NULL; |
78 } | 78 } |
79 | 79 |
80 // Override SQLiteCursor::TestObserver. | 80 // Override SQLiteCursor::TestObserver. |
81 void OnPostMoveToTask() override { base::MessageLoop::current()->Run(); } | 81 void OnPostMoveToTask() override { base::MessageLoop::current()->Run(); } |
82 | 82 |
83 void OnGetMoveToResult() override { base::MessageLoop::current()->Quit(); } | 83 void OnGetMoveToResult() override { |
| 84 base::MessageLoop::current()->QuitWhenIdle(); |
| 85 } |
84 | 86 |
85 void OnPostGetFaviconTask() override { base::MessageLoop::current()->Run(); } | 87 void OnPostGetFaviconTask() override { base::MessageLoop::current()->Run(); } |
86 | 88 |
87 void OnGetFaviconResult() override { base::MessageLoop::current()->Quit(); } | 89 void OnGetFaviconResult() override { |
| 90 base::MessageLoop::current()->QuitWhenIdle(); |
| 91 } |
88 | 92 |
89 protected: | 93 protected: |
90 TestingProfileManager profile_manager_; | 94 TestingProfileManager profile_manager_; |
91 base::MessageLoop message_loop_; | 95 base::MessageLoop message_loop_; |
92 content::TestBrowserThread ui_thread_; | 96 content::TestBrowserThread ui_thread_; |
93 content::TestBrowserThread file_thread_; | 97 content::TestBrowserThread file_thread_; |
94 scoped_ptr<AndroidHistoryProviderService> service_; | 98 scoped_ptr<AndroidHistoryProviderService> service_; |
95 base::CancelableTaskTracker cancelable_tracker_; | 99 base::CancelableTaskTracker cancelable_tracker_; |
96 TestingProfile* testing_profile_; | 100 TestingProfile* testing_profile_; |
97 history::HistoryService* hs_; | 101 history::HistoryService* hs_; |
(...skipping 12 matching lines...) Expand all Loading... |
110 bool success() const { | 114 bool success() const { |
111 return success_; | 115 return success_; |
112 } | 116 } |
113 | 117 |
114 AndroidStatement* statement() const { | 118 AndroidStatement* statement() const { |
115 return statement_; | 119 return statement_; |
116 } | 120 } |
117 | 121 |
118 void OnInserted(int64 id) { | 122 void OnInserted(int64 id) { |
119 success_ = id != 0; | 123 success_ = id != 0; |
120 base::MessageLoop::current()->Quit(); | 124 base::MessageLoop::current()->QuitWhenIdle(); |
121 } | 125 } |
122 | 126 |
123 void OnQueryResult(AndroidStatement* statement) { | 127 void OnQueryResult(AndroidStatement* statement) { |
124 success_ = statement != NULL; | 128 success_ = statement != NULL; |
125 statement_ = statement; | 129 statement_ = statement; |
126 base::MessageLoop::current()->Quit(); | 130 base::MessageLoop::current()->QuitWhenIdle(); |
127 } | 131 } |
128 | 132 |
129 private: | 133 private: |
130 friend class base::RefCountedThreadSafe<CallbackHelper>; | 134 friend class base::RefCountedThreadSafe<CallbackHelper>; |
131 ~CallbackHelper() { | 135 ~CallbackHelper() { |
132 } | 136 } |
133 | 137 |
134 bool success_; | 138 bool success_; |
135 AndroidStatement* statement_; | 139 AndroidStatement* statement_; |
136 | 140 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 cursor->GetBlob(env, NULL, 3); | 209 cursor->GetBlob(env, NULL, 3); |
206 std::vector<uint8> out; | 210 std::vector<uint8> out; |
207 base::android::JavaByteArrayToByteVector(env, data.obj(), &out); | 211 base::android::JavaByteArrayToByteVector(env, data.obj(), &out); |
208 EXPECT_EQ(data_bytes->data().size(), out.size()); | 212 EXPECT_EQ(data_bytes->data().size(), out.size()); |
209 EXPECT_EQ(data_bytes->data()[0], out[0]); | 213 EXPECT_EQ(data_bytes->data()[0], out[0]); |
210 cursor->Destroy(env, NULL); | 214 cursor->Destroy(env, NULL); |
211 // Cursor::Destroy posts the task in UI thread, run Message loop to release | 215 // Cursor::Destroy posts the task in UI thread, run Message loop to release |
212 // the statement, delete SQLiteCursor itself etc. | 216 // the statement, delete SQLiteCursor itself etc. |
213 content::RunAllPendingInMessageLoop(); | 217 content::RunAllPendingInMessageLoop(); |
214 } | 218 } |
OLD | NEW |