Bug 709230 - Part 3: annotate the remaining Robocop entry points. r=gbrown,rnewman

This commit is contained in:
Chris Kitching 2013-11-18 21:09:00 -08:00
parent d8774392af
commit ae8356f784
20 changed files with 83 additions and 22 deletions

View File

@ -6,6 +6,7 @@
package org.mozilla.gecko;
import org.mozilla.gecko.mozglue.RobocopTarget;
/**
* A collection of constants that pertain to the build and runtime state of the
* application. Typically these are sourced from build-time definitions (see
@ -15,6 +16,7 @@ package org.mozilla.gecko;
* See also SysInfo.java, which includes some of the values available from
* nsSystemInfo inside Gecko.
*/
@RobocopTarget
public class AppConstants {
public static final String ANDROID_PACKAGE_NAME = "@ANDROID_PACKAGE_NAME@";
public static final String BROWSER_INTENT_CLASS = ANDROID_PACKAGE_NAME + ".App";

View File

@ -5,6 +5,7 @@
package org.mozilla.gecko;
import org.mozilla.gecko.mozglue.RobocopTarget;
import org.mozilla.gecko.util.ThreadUtils;
import org.json.JSONArray;
@ -87,6 +88,7 @@ public final class Distribution {
*
* @param packagePath where to look for the distribution directory.
*/
@RobocopTarget
public static void init(final Context context, final String packagePath, final String prefsPath) {
// Read/write preferences and files on the background thread.
ThreadUtils.postToBackgroundThread(new Runnable() {

View File

@ -392,7 +392,6 @@ public class GeckoAppShell
} catch (NoSuchElementException e) {}
}
/* This method is referenced by Robocop via reflection. */
public static void sendEventToGecko(GeckoEvent e) {
if (GeckoThread.checkLaunchState(GeckoThread.LaunchState.GeckoRunning)) {
notifyGeckoOfEvent(e);
@ -2322,8 +2321,6 @@ public class GeckoAppShell
* with an event that is currently being processed has the properly-defined behaviour that
* any added listeners will not be invoked on the event currently being processed, but
* will be invoked on future events of that type.
*
* This method is referenced by Robocop via reflection.
*/
public static void registerEventListener(String event, GeckoEventListener listener) {
sEventDispatcher.registerEventListener(event, listener);
@ -2339,8 +2336,6 @@ public class GeckoAppShell
* with an event that is currently being processed has the properly-defined behaviour that
* any removed listeners will still be invoked on the event currently being processed, but
* will not be invoked on future events of that type.
*
* This method is referenced by Robocop via reflection.
*/
public static void unregisterEventListener(String event, GeckoEventListener listener) {
sEventDispatcher.unregisterEventListener(event, listener);

View File

@ -6,12 +6,12 @@
package org.mozilla.gecko;
import org.mozilla.gecko.mozglue.GeckoLoader;
import org.mozilla.gecko.mozglue.RobocopTarget;
import org.mozilla.gecko.util.GeckoEventListener;
import org.mozilla.gecko.util.ThreadUtils;
import org.json.JSONObject;
import android.content.Intent;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
@ -28,6 +28,7 @@ import java.util.Locale;
public class GeckoThread extends Thread implements GeckoEventListener {
private static final String LOGTAG = "GeckoThread";
@RobocopTarget
public enum LaunchState {
Launching,
WaitForDebugger,
@ -187,6 +188,7 @@ public class GeckoThread extends Thread implements GeckoEventListener {
}
}
@RobocopTarget
public static boolean checkLaunchState(LaunchState checkState) {
synchronized (sLock) {
return sLaunchState == checkState;

View File

@ -7,6 +7,7 @@ package org.mozilla.gecko;
import org.mozilla.gecko.mozglue.GeckoLoader;
import android.content.Context;
import org.mozilla.gecko.mozglue.RobocopTarget;
public class NSSBridge {
private static final String LOGTAG = "NSSBridge";
@ -14,6 +15,7 @@ public class NSSBridge {
private static native String nativeEncrypt(String aDb, String aValue);
private static native String nativeDecrypt(String aDb, String aValue);
@RobocopTarget
static public String encrypt(Context context, String aValue)
throws Exception {
String resourcePath = context.getPackageResourcePath();
@ -23,6 +25,7 @@ public class NSSBridge {
return nativeEncrypt(path, aValue);
}
@RobocopTarget
static public String encrypt(Context context, String profilePath, String aValue)
throws Exception {
String resourcePath = context.getPackageResourcePath();
@ -31,6 +34,7 @@ public class NSSBridge {
return nativeEncrypt(profilePath, aValue);
}
@RobocopTarget
static public String decrypt(Context context, String aValue)
throws Exception {
String resourcePath = context.getPackageResourcePath();
@ -40,6 +44,7 @@ public class NSSBridge {
return nativeDecrypt(path, aValue);
}
@RobocopTarget
static public String decrypt(Context context, String profilePath, String aValue)
throws Exception {
String resourcePath = context.getPackageResourcePath();

View File

@ -4,12 +4,11 @@
package org.mozilla.gecko;
import android.content.Context;
import org.mozilla.gecko.gfx.GeckoLayerClient;
import org.mozilla.gecko.gfx.LayerView;
import org.mozilla.gecko.gfx.PanningPerfAPI;
import org.mozilla.gecko.mozglue.GeckoLoader;
import org.mozilla.gecko.mozglue.RobocopJNITarget;
import org.mozilla.gecko.mozglue.RobocopTarget;
import org.mozilla.gecko.sqlite.SQLiteBridge;
import org.mozilla.gecko.util.GeckoEventListener;
@ -38,6 +37,7 @@ import java.util.List;
* also not prone to vanishing at compile-time, but doing this might substantially complicate your
* work, ultimately not proving worth the extra effort to avoid making a slight mess here.
*/
@RobocopTarget
public class RobocopAPI {
private final GeckoApp mGeckoApp;

View File

@ -9,6 +9,7 @@ import org.mozilla.gecko.db.BrowserDB;
import org.mozilla.gecko.favicons.Favicons;
import org.mozilla.gecko.home.HomePager;
import org.mozilla.gecko.mozglue.JNITarget;
import org.mozilla.gecko.mozglue.RobocopTarget;
import org.mozilla.gecko.sync.setup.SyncAccounts;
import org.mozilla.gecko.util.GeckoEventListener;
import org.mozilla.gecko.util.ThreadUtils;
@ -375,6 +376,7 @@ public class Tabs implements GeckoEventListener {
private static final Tabs INSTANCE = new Tabs();
}
@RobocopTarget
public static Tabs getInstance() {
return Tabs.TabsInstanceHolder.INSTANCE;
}
@ -667,6 +669,7 @@ public class Tabs implements GeckoEventListener {
*
* @param url URL of page to load, or search term used if searchEngine is given
*/
@RobocopTarget
public Tab loadUrl(String url) {
return loadUrl(url, LOADURL_NONE);
}

View File

@ -8,7 +8,9 @@ package org.mozilla.gecko.db;
import org.mozilla.gecko.AppConstants;
import android.net.Uri;
import org.mozilla.gecko.mozglue.RobocopTarget;
@RobocopTarget
public class BrowserContract {
public static final String AUTHORITY = AppConstants.ANDROID_PACKAGE_NAME + ".db.browser";
public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY);
@ -50,31 +52,37 @@ public class BrowserContract {
return order.toString();
}
@RobocopTarget
public interface CommonColumns {
public static final String _ID = "_id";
}
@RobocopTarget
public interface DateSyncColumns {
public static final String DATE_CREATED = "created";
public static final String DATE_MODIFIED = "modified";
}
@RobocopTarget
public interface SyncColumns extends DateSyncColumns {
public static final String GUID = "guid";
public static final String IS_DELETED = "deleted";
}
@RobocopTarget
public interface URLColumns {
public static final String URL = "url";
public static final String TITLE = "title";
}
@RobocopTarget
public interface FaviconColumns {
public static final String FAVICON = "favicon";
public static final String FAVICON_ID = "favicon_id";
public static final String FAVICON_URL = "favicon_url";
}
@RobocopTarget
public interface HistoryColumns {
public static final String DATE_LAST_VISITED = "date";
public static final String VISITS = "visits";
@ -86,6 +94,7 @@ public class BrowserContract {
public static final String TIME_DELETED = "timeDeleted";
}
@RobocopTarget
public static final class Favicons implements CommonColumns, DateSyncColumns {
private Favicons() {}
@ -96,6 +105,7 @@ public class BrowserContract {
public static final String PAGE_URL = "page_url";
}
@RobocopTarget
public static final class Thumbnails implements CommonColumns {
private Thumbnails() {}
@ -105,6 +115,7 @@ public class BrowserContract {
public static final String DATA = "data";
}
@RobocopTarget
public static final class Bookmarks implements CommonColumns, URLColumns, FaviconColumns, SyncColumns {
private Bookmarks() {}
@ -145,6 +156,7 @@ public class BrowserContract {
public static final String KEYWORD = "keyword";
}
@RobocopTarget
public static final class History implements CommonColumns, URLColumns, HistoryColumns, FaviconColumns, SyncColumns {
private History() {}
public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "history");
@ -154,6 +166,7 @@ public class BrowserContract {
}
// Combined bookmarks and history
@RobocopTarget
public static final class Combined implements CommonColumns, URLColumns, HistoryColumns, FaviconColumns {
private Combined() {}
public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "combined");

View File

@ -7,6 +7,7 @@ package org.mozilla.gecko.db;
import org.mozilla.gecko.db.BrowserContract.Bookmarks;
import org.mozilla.gecko.db.BrowserContract.ExpirePriority;
import org.mozilla.gecko.mozglue.RobocopTarget;
import android.content.ContentResolver;
import android.database.ContentObserver;
@ -36,6 +37,7 @@ public class BrowserDB {
public interface BrowserDBIface {
public void invalidateCachedState();
@RobocopTarget
public Cursor filter(ContentResolver cr, CharSequence constraint, int limit);
// This should onlyl return frecent sites, BrowserDB.getTopSites will do the
@ -49,6 +51,7 @@ public class BrowserDB {
public void updateHistoryEntry(ContentResolver cr, String uri, String title,
long date, int visits);
@RobocopTarget
public Cursor getAllVisitedHistory(ContentResolver cr);
public Cursor getRecentHistory(ContentResolver cr, int limit);
@ -57,28 +60,34 @@ public class BrowserDB {
public void removeHistoryEntry(ContentResolver cr, int id);
@RobocopTarget
public void removeHistoryEntry(ContentResolver cr, String url);
public void clearHistory(ContentResolver cr);
@RobocopTarget
public Cursor getBookmarksInFolder(ContentResolver cr, long folderId);
public boolean isVisited(ContentResolver cr, String uri);
public int getReadingListCount(ContentResolver cr);
@RobocopTarget
public boolean isBookmark(ContentResolver cr, String uri);
public boolean isReadingListItem(ContentResolver cr, String uri);
public String getUrlForKeyword(ContentResolver cr, String keyword);
@RobocopTarget
public void addBookmark(ContentResolver cr, String title, String uri);
public void removeBookmark(ContentResolver cr, int id);
@RobocopTarget
public void removeBookmarksWithURL(ContentResolver cr, String uri);
@RobocopTarget
public void updateBookmark(ContentResolver cr, int id, String uri, String title, String keyword);
public void addReadingListItem(ContentResolver cr, String title, String uri);
@ -93,10 +102,12 @@ public class BrowserDB {
public void updateThumbnailForUrl(ContentResolver cr, String uri, BitmapDrawable thumbnail);
@RobocopTarget
public byte[] getThumbnailForUrl(ContentResolver cr, String uri);
public Cursor getThumbnailsForUrls(ContentResolver cr, List<String> urls);
@RobocopTarget
public void removeThumbnails(ContentResolver cr);
public void registerBookmarkObserver(ContentResolver cr, ContentObserver observer);
@ -113,6 +124,7 @@ public class BrowserDB {
public Cursor getPinnedSites(ContentResolver cr, int limit);
@RobocopTarget
public Cursor getBookmarkForUrl(ContentResolver cr, String url);
}
@ -129,6 +141,7 @@ public class BrowserDB {
sDb.invalidateCachedState();
}
@RobocopTarget
public static Cursor filter(ContentResolver cr, CharSequence constraint, int limit) {
return sDb.filter(cr, constraint, limit);
}
@ -160,6 +173,7 @@ public class BrowserDB {
}
}
@RobocopTarget
public static Cursor getAllVisitedHistory(ContentResolver cr) {
return (sAreContentProvidersEnabled ? sDb.getAllVisitedHistory(cr) : null);
}
@ -181,14 +195,17 @@ public class BrowserDB {
sDb.removeHistoryEntry(cr, id);
}
@RobocopTarget
public static void removeHistoryEntry(ContentResolver cr, String url) {
sDb.removeHistoryEntry(cr, url);
}
@RobocopTarget
public static void clearHistory(ContentResolver cr) {
sDb.clearHistory(cr);
}
@RobocopTarget
public static Cursor getBookmarksInFolder(ContentResolver cr, long folderId) {
return sDb.getBookmarksInFolder(cr, folderId);
}
@ -205,6 +222,7 @@ public class BrowserDB {
return sDb.getReadingListCount(cr);
}
@RobocopTarget
public static boolean isBookmark(ContentResolver cr, String uri) {
return (sAreContentProvidersEnabled && sDb.isBookmark(cr, uri));
}
@ -221,10 +239,12 @@ public class BrowserDB {
sDb.removeBookmark(cr, id);
}
@RobocopTarget
public static void removeBookmarksWithURL(ContentResolver cr, String uri) {
sDb.removeBookmarksWithURL(cr, uri);
}
@RobocopTarget
public static void updateBookmark(ContentResolver cr, int id, String uri, String title, String keyword) {
sDb.updateBookmark(cr, id, uri, title, keyword);
}
@ -253,6 +273,7 @@ public class BrowserDB {
sDb.updateThumbnailForUrl(cr, uri, thumbnail);
}
@RobocopTarget
public static byte[] getThumbnailForUrl(ContentResolver cr, String uri) {
return sDb.getThumbnailForUrl(cr, uri);
}
@ -261,6 +282,7 @@ public class BrowserDB {
return sDb.getThumbnailsForUrls(cr, urls);
}
@RobocopTarget
public static void removeThumbnails(ContentResolver cr) {
sDb.removeThumbnails(cr);
}
@ -297,6 +319,7 @@ public class BrowserDB {
return sDb.getPinnedSites(cr, limit);
}
@RobocopTarget
public static Cursor getBookmarkForUrl(ContentResolver cr, String url) {
return sDb.getBookmarkForUrl(cr, url);
}

View File

@ -20,6 +20,7 @@ import org.mozilla.gecko.db.BrowserContract.SyncColumns;
import org.mozilla.gecko.db.BrowserContract.Thumbnails;
import org.mozilla.gecko.db.BrowserContract.URLColumns;
import org.mozilla.gecko.gfx.BitmapUtils;
import org.mozilla.gecko.mozglue.RobocopTarget;
import org.mozilla.gecko.sync.Utils;
import org.mozilla.gecko.util.GeckoJarReader;
import org.mozilla.gecko.util.ThreadUtils;
@ -1991,6 +1992,7 @@ public class BrowserProvider extends ContentProvider {
return dbHelper;
}
@RobocopTarget
public String getDatabasePath(String profile, boolean isTest) {
trace("Getting database path for profile: " + profile);

View File

@ -12,9 +12,7 @@ import java.util.Map;
import org.mozilla.gecko.GeckoProfile;
import org.mozilla.gecko.db.BrowserContract.Clients;
import org.mozilla.gecko.db.BrowserContract.Tabs;
import org.mozilla.gecko.db.BrowserContract;
import org.mozilla.gecko.db.DBUtils;
import org.mozilla.gecko.util.ThreadUtils;
import org.mozilla.gecko.mozglue.RobocopTarget;
import android.content.ContentProvider;
import android.content.ContentUris;
@ -248,6 +246,7 @@ public class TabsProvider extends ContentProvider {
return dbHelper;
}
@RobocopTarget
private String getDatabasePath(String profile) {
trace("Getting database path for profile: " + profile);

View File

@ -5,16 +5,15 @@
package org.mozilla.gecko.gfx;
import org.mozilla.gecko.BrowserApp;
import org.mozilla.gecko.GeckoAppShell;
import org.mozilla.gecko.GeckoEvent;
import org.mozilla.gecko.Tab;
import org.mozilla.gecko.Tabs;
import org.mozilla.gecko.ZoomConstraints;
import org.mozilla.gecko.mozglue.RobocopTarget;
import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
import org.mozilla.gecko.util.EventDispatcher;
import org.mozilla.gecko.util.FloatUtils;
import org.mozilla.gecko.util.ThreadUtils;
import android.content.Context;
import android.graphics.PointF;
@ -56,7 +55,6 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
*/
private ImmutableViewportMetrics mFrameMetrics;
/* Used by robocop for testing purposes */
private DrawListener mDrawListener;
/* Used as temporaries by syncViewportInfo */
@ -975,11 +973,13 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
}
/** Used by robocop for testing purposes. Not for production use! */
@RobocopTarget
public void setDrawListener(DrawListener listener) {
mDrawListener = listener;
}
/** Used by robocop for testing purposes. Not for production use! */
@RobocopTarget
public static interface DrawListener {
public void drawFinished();
}

View File

@ -82,7 +82,6 @@ public class LayerRenderer implements Tabs.OnTabsChangedListener {
private boolean mProfileRender;
private long mProfileOutputTime;
/* Used by robocop for testing purposes */
private IntBuffer mPixelBuffer;
// Used by GLES 2.0

View File

@ -15,6 +15,7 @@ import org.mozilla.gecko.db.BrowserDB.URLColumns;
import org.mozilla.gecko.home.HomePager.OnUrlOpenListener;
import org.mozilla.gecko.home.SearchEngine;
import org.mozilla.gecko.home.SearchLoader.SearchCursorLoader;
import org.mozilla.gecko.mozglue.RobocopTarget;
import org.mozilla.gecko.toolbar.AutocompleteHandler;
import org.mozilla.gecko.util.GeckoEventListener;
import org.mozilla.gecko.util.StringUtils;
@ -27,10 +28,8 @@ import org.json.JSONObject;
import android.app.Activity;
import android.content.Context;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.LoaderManager;
import android.support.v4.app.LoaderManager.LoaderCallbacks;
import android.support.v4.content.AsyncTaskLoader;
import android.support.v4.content.Loader;
@ -96,6 +95,7 @@ public class BrowserSearch extends HomeFragment
private HomeListView mList;
// Client that performs search suggestion queries
@RobocopTarget
private volatile SuggestClient mSuggestClient;
// List of search engines from gecko

View File

@ -13,6 +13,7 @@ import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.text.TextUtils;
import android.util.Log;
import org.mozilla.gecko.mozglue.RobocopTarget;
import java.io.BufferedInputStream;
import java.io.IOException;
@ -56,6 +57,7 @@ class SuggestClient {
/**
* This constructor is used exclusively by Robocop.
*/
@RobocopTarget
public SuggestClient(Context context, String suggestTemplate, int timeout) {
this(context, suggestTemplate, timeout, Integer.MAX_VALUE);
mCheckNetwork = false;

View File

@ -21,6 +21,7 @@ mgjar.sources += [
'mozglue/JNITarget.java',
'mozglue/NativeReference.java',
'mozglue/NativeZip.java',
'mozglue/RobocopTarget.java',
]
mgjar.generated_sources += [
'org/mozilla/gecko/mozglue/GeckoLoader.java',

View File

@ -0,0 +1,12 @@
/* 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.mozglue;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.CLASS)
public @interface RobocopTarget {}

View File

@ -10,6 +10,7 @@ import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.text.TextUtils;
import android.util.Log;
import org.mozilla.gecko.mozglue.RobocopTarget;
import java.util.ArrayList;
import java.util.Map.Entry;
@ -120,7 +121,7 @@ public class SQLiteBridge {
return rawQuery(sb.toString(), selectionArgs);
}
/* This method is referenced by Robocop via reflection. */
@RobocopTarget
public Cursor rawQuery(String sql, String[] selectionArgs)
throws SQLiteBridgeException {
return internalQuery(sql, selectionArgs);

View File

@ -6,10 +6,9 @@
package org.mozilla.gecko.util;
import org.json.JSONObject;
import org.mozilla.gecko.mozglue.RobocopTarget;
/* This class is referenced by Robocop via reflection; use care when
* modifying the signature.
*/
@RobocopTarget
public interface GeckoEventListener {
void handleMessage(String event, JSONObject message);
}

View File

@ -10,6 +10,7 @@ import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.util.Log;
import org.mozilla.gecko.mozglue.RobocopTarget;
import java.io.BufferedReader;
import java.io.IOException;
@ -98,7 +99,7 @@ public final class GeckoJarReader {
return new NativeZip(fileUrl.getPath());
}
// Public for testing only.
@RobocopTarget
public static InputStream getStream(String url) {
Stack<String> jarUrls = parseUrl(url);
try {