Bug 927371 - Remove performEmptySearch from SearchLoader (r=sriram)
authorLucas Rocha <lucasr@mozilla.com>
Wed, 16 Oct 2013 17:02:02 +0100
changeset 165753 d0cf13b1749a891948e8f06aa1ea7a3da1595e3a
parent 165752 60ff0c915b5c80f4085a5273693f74b3d74fc05c
child 165754 1b53a6a4d2dedc64cdeb899f8b7f4bb3d08b9751
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssriram
bugs927371
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 927371 - Remove performEmptySearch from SearchLoader (r=sriram)
mobile/android/base/home/BrowserSearch.java
mobile/android/base/home/SearchLoader.java
--- a/mobile/android/base/home/BrowserSearch.java
+++ b/mobile/android/base/home/BrowserSearch.java
@@ -316,17 +316,17 @@ public class BrowserSearch extends HomeF
                     setSearchEngines(message);
                 }
             });
         }
     }
 
     @Override
     protected void load() {
-        SearchLoader.init(getLoaderManager(), LOADER_ID_SEARCH, mCursorLoaderCallbacks, mSearchTerm, false);
+        SearchLoader.init(getLoaderManager(), LOADER_ID_SEARCH, mCursorLoaderCallbacks, mSearchTerm);
     }
 
     private void handleAutocomplete(String searchTerm, Cursor c) {
         if (TextUtils.isEmpty(mSearchTerm) || c == null || mAutocompleteHandler == null) {
             return;
         }
 
         // Avoid searching the path if we don't have to. Currently just
@@ -607,17 +607,17 @@ public class BrowserSearch extends HomeF
         mAutocompleteHandler = handler;
 
         if (isVisible()) {
             // The adapter depends on the search term to determine its number
             // of items. Make it we notify the view about it.
             mAdapter.notifyDataSetChanged();
 
             // Restart loaders with the new search term
-            SearchLoader.restart(getLoaderManager(), LOADER_ID_SEARCH, mCursorLoaderCallbacks, mSearchTerm, false);
+            SearchLoader.restart(getLoaderManager(), LOADER_ID_SEARCH, mCursorLoaderCallbacks, mSearchTerm);
             filterSuggestions();
         }
     }
 
     private static class SuggestionAsyncLoader extends AsyncTaskLoader<ArrayList<String>> {
         private final SuggestClient mSuggestClient;
         private final String mSearchTerm;
         private ArrayList<String> mSuggestions;
--- a/mobile/android/base/home/SearchLoader.java
+++ b/mobile/android/base/home/SearchLoader.java
@@ -17,79 +17,61 @@ import android.text.TextUtils;
 
 /**
  * Encapsulates the implementation of the search cursor loader.
  */
 class SearchLoader {
     // Key for search terms
     private static final String KEY_SEARCH_TERM = "search_term";
 
-    // Key for performing empty search
-    private static final String KEY_PERFORM_EMPTY_SEARCH = "perform_empty_search";
-
     private SearchLoader() {
     }
 
     public static Loader<Cursor> createInstance(Context context, Bundle args) {
         if (args != null) {
             final String searchTerm = args.getString(KEY_SEARCH_TERM);
-            final boolean performEmptySearch = args.getBoolean(KEY_PERFORM_EMPTY_SEARCH, false);
-            return new SearchCursorLoader(context, searchTerm, performEmptySearch);
+            return new SearchCursorLoader(context, searchTerm);
         } else {
-            return new SearchCursorLoader(context, "", false);
+            return new SearchCursorLoader(context, "");
         }
     }
 
-    private static Bundle createArgs(String searchTerm, boolean performEmptySearch) {
+    private static Bundle createArgs(String searchTerm) {
         Bundle args = new Bundle();
         args.putString(SearchLoader.KEY_SEARCH_TERM, searchTerm);
-        args.putBoolean(SearchLoader.KEY_PERFORM_EMPTY_SEARCH, performEmptySearch);
 
         return args;
     }
 
     public static void init(LoaderManager manager, int loaderId,
-                               LoaderCallbacks<Cursor> callbacks, String searchTerm, boolean performEmptySearch) {
-        Bundle args = createArgs(searchTerm, performEmptySearch);
+                               LoaderCallbacks<Cursor> callbacks, String searchTerm) {
+        final Bundle args = createArgs(searchTerm);
         manager.initLoader(loaderId, args, callbacks);
     }
 
     public static void restart(LoaderManager manager, int loaderId,
                                LoaderCallbacks<Cursor> callbacks, String searchTerm) {
-        restart(manager, loaderId, callbacks, searchTerm, true);
-    }
-
-    public static void restart(LoaderManager manager, int loaderId,
-                               LoaderCallbacks<Cursor> callbacks, String searchTerm, boolean performEmptySearch) {
-        Bundle args = createArgs(searchTerm, performEmptySearch);
+        final Bundle args = createArgs(searchTerm);
         manager.restartLoader(loaderId, args, callbacks);
     }
 
     public static class SearchCursorLoader extends SimpleCursorLoader {
         // Max number of search results
         private static final int SEARCH_LIMIT = 100;
 
         // The target search term associated with the loader
         private final String mSearchTerm;
 
-        // An empty search on the DB
-        private final boolean mPerformEmptySearch;
-
-        public SearchCursorLoader(Context context, String searchTerm, boolean performEmptySearch) {
+        public SearchCursorLoader(Context context, String searchTerm) {
             super(context);
             mSearchTerm = searchTerm;
-            mPerformEmptySearch = performEmptySearch;
         }
 
         @Override
         public Cursor loadCursor() {
-            if (!mPerformEmptySearch && TextUtils.isEmpty(mSearchTerm)) {
-                return null;
-            }
-
             return BrowserDB.filter(getContext().getContentResolver(), mSearchTerm, SEARCH_LIMIT);
         }
 
         public String getSearchTerm() {
             return mSearchTerm;
         }
     }