Bug 735475 - Invert AndroidBrowserRepositorySession.checkRecordType into shouldIgnore. r=nalexander
authorRichard Newman <rnewman@mozilla.com>
Tue, 13 Mar 2012 15:48:26 -0700
changeset 92300 0339a626ec58018cdfc3b279e7a336770dd73eec
parent 92299 699d3936575be3417ec820b7861d2cea0099cea4
child 92301 97741a41d74f48114112900dbcace3272f78b352
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs735475
milestone14.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 735475 - Invert AndroidBrowserRepositorySession.checkRecordType into shouldIgnore. r=nalexander
mobile/android/base/sync/repositories/android/AndroidBrowserBookmarksRepositorySession.java
mobile/android/base/sync/repositories/android/AndroidBrowserRepositorySession.java
--- a/mobile/android/base/sync/repositories/android/AndroidBrowserBookmarksRepositorySession.java
+++ b/mobile/android/base/sync/repositories/android/AndroidBrowserBookmarksRepositorySession.java
@@ -454,31 +454,31 @@ public class AndroidBrowserBookmarksRepo
       return null;
     }
 
     Logger.debug(LOG_TAG, "Fetched " + childArray.size() + " children for " + recordGUID);
     return childArray;
   }
 
   @Override
-  protected boolean checkRecordType(Record record) {
+  protected boolean shouldIgnore(Record record) {
     if (!(record instanceof BookmarkRecord)) {
-      return false;
+      return true;
     }
     if (record.deleted) {
-      return true;
+      return false;
     }
     BookmarkRecord bmk = (BookmarkRecord) record;
 
     if (bmk.isBookmark() ||
         bmk.isFolder()) {
-      return true;
+      return false;
     }
     Logger.info(LOG_TAG, "Ignoring record with guid: " + bmk.guid + " and type: " + bmk.type);
-    return false;
+    return true;
   }
   
   @Override
   public void begin(RepositorySessionBeginDelegate delegate) throws InvalidSessionTransitionException {
     // Check for the existence of special folders
     // and insert them if they don't exist.
     Cursor cur;
     try {
--- a/mobile/android/base/sync/repositories/android/AndroidBrowserRepositorySession.java
+++ b/mobile/android/base/sync/repositories/android/AndroidBrowserRepositorySession.java
@@ -1,45 +1,11 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Android Sync Client.
- *
- * The Initial Developer of the Original Code is
- * the Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2011
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Jason Voll <jvoll@mozilla.com>
- *   Richard Newman <rnewman@mozilla.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.sync.repositories.android;
 
 import java.util.ArrayList;
 import java.util.HashMap;
 
 import org.mozilla.gecko.sync.Logger;
 import org.mozilla.gecko.sync.repositories.InactiveSessionException;
@@ -113,19 +79,23 @@ public abstract class AndroidBrowserRepo
    * of a folder might be repositioned as we generate the folder's record.
    *
    * @throws NoGuidForIdException
    * @throws NullCursorException
    * @throws ParentNotFoundException
    */
   protected abstract Record retrieveDuringFetch(Cursor cur) throws NoGuidForIdException, NullCursorException, ParentNotFoundException;
 
-  // Must be overriden by AndroidBookmarkRepositorySession.
-  protected boolean checkRecordType(Record record) {
-    return true;
+  /**
+   * Override this to allow records to be skipped during insertion.
+   *
+   * For example, a session subclass might skip records of an unsupported type.
+   */
+  protected boolean shouldIgnore(Record record) {
+    return false;
   }
 
   /**
    * Override in subclass to implement record extension.
    * Return null if this record should not be processed.
    *
    * @param record
    *        The record to transform. Can be null.
@@ -388,18 +358,18 @@ public abstract class AndroidBrowserRepo
           return;
         }
 
         // Check that the record is a valid type.
         // Fennec only supports bookmarks and folders. All other types of records,
         // including livemarks and queries, are simply ignored.
         // See Bug 708149. This might be resolved by Fennec changing its database
         // schema, or by Sync storing non-applied records in its own private database.
-        if (!checkRecordType(record)) {
-          Logger.debug(LOG_TAG, "Ignoring record " + record.guid + " due to unknown record type.");
+        if (shouldIgnore(record)) {
+          Logger.debug(LOG_TAG, "Ignoring record " + record.guid);
 
           // Don't throw: we don't want to abort the entire sync when we get a livemark!
           // delegate.onRecordStoreFailed(new InvalidBookmarkTypeException(null));
           return;
         }
 
 
         // TODO: lift these into the session.