Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 package org.chromium.chrome.browser.bookmark; | 5 package org.chromium.chrome.browser.bookmark; |
| 6 | 6 |
| 7 import android.util.Pair; | 7 import android.util.Pair; |
| 8 | 8 |
| 9 import org.chromium.base.ObserverList; | 9 import org.chromium.base.ObserverList; |
| 10 import org.chromium.base.VisibleForTesting; | 10 import org.chromium.base.VisibleForTesting; |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 } | 200 } |
| 201 | 201 |
| 202 /** | 202 /** |
| 203 * @return Whether or not the underlying bookmark model is loaded. | 203 * @return Whether or not the underlying bookmark model is loaded. |
| 204 */ | 204 */ |
| 205 public boolean isBookmarkModelLoaded() { | 205 public boolean isBookmarkModelLoaded() { |
| 206 return mIsNativeBookmarkModelLoaded; | 206 return mIsNativeBookmarkModelLoaded; |
| 207 } | 207 } |
| 208 | 208 |
| 209 /** | 209 /** |
| 210 * If bookmark model is loaded, execute the runnable immediately; otherwise schedule the | |
|
newt (away)
2015/11/19 23:29:28
s/execute/executes/
javadocs should describe what
Ian Wen
2015/12/01 09:17:14
Done.
| |
| 211 * runnable till the model is loaded. | |
| 212 * @return Whether the given runnable is executed synchronously. | |
| 213 */ | |
| 214 public boolean doAfterBookmarkModelLoaded(final Runnable runnable) { | |
|
newt (away)
2015/11/19 23:29:28
s/do/run/ to use consistent terminology
Ian Wen
2015/12/01 09:17:14
Done.
| |
| 215 if (isBookmarkModelLoaded()) { | |
| 216 runnable.run(); | |
| 217 return true; | |
| 218 } | |
| 219 addObserver(new BookmarkModelObserver() { | |
| 220 @Override | |
| 221 public void bookmarkModelLoaded() { | |
| 222 removeObserver(this); | |
| 223 runnable.run(); | |
| 224 } | |
| 225 @Override | |
| 226 public void bookmarkModelChanged() { | |
| 227 } | |
| 228 }); | |
| 229 return false; | |
| 230 } | |
| 231 | |
| 232 /** | |
| 210 * @return A BookmarkItem instance for the given BookmarkId. | 233 * @return A BookmarkItem instance for the given BookmarkId. |
| 211 * <code>null</code> if it doesn't exist. | 234 * <code>null</code> if it doesn't exist. |
| 212 */ | 235 */ |
| 213 public BookmarkItem getBookmarkById(BookmarkId id) { | 236 public BookmarkItem getBookmarkById(BookmarkId id) { |
| 214 assert mIsNativeBookmarkModelLoaded; | 237 assert mIsNativeBookmarkModelLoaded; |
| 215 return nativeGetBookmarkByID(mNativeBookmarksBridge, id.getId(), id.getT ype()); | 238 return nativeGetBookmarkByID(mNativeBookmarksBridge, id.getId(), id.getT ype()); |
| 216 } | 239 } |
| 217 | 240 |
| 218 /** | 241 /** |
| 219 * @return All the permanent nodes. | 242 * @return All the permanent nodes. |
| (...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 876 case GET_CURRENT_FOLDER_HIERARCHY: | 899 case GET_CURRENT_FOLDER_HIERARCHY: |
| 877 mHandler.getCurrentFolderHierarchy(mFolderId, mCallback); | 900 mHandler.getCurrentFolderHierarchy(mFolderId, mCallback); |
| 878 break; | 901 break; |
| 879 default: | 902 default: |
| 880 assert false; | 903 assert false; |
| 881 break; | 904 break; |
| 882 } | 905 } |
| 883 } | 906 } |
| 884 } | 907 } |
| 885 } | 908 } |
| OLD | NEW |