|
| 1 | +/* |
| 2 | + * Copyright (c) 2014-present, Facebook, Inc. |
| 3 | + * All rights reserved. |
| 4 | + * |
| 5 | + * This source code is licensed under the BSD-style license found in the |
| 6 | + * LICENSE file in the root directory of this source tree. An additional grant |
| 7 | + * of patent rights can be found in the PATENTS file in the same directory. |
| 8 | + */ |
| 9 | + |
| 10 | +package com.facebook.stetho; |
| 11 | + |
| 12 | +import android.content.Context; |
| 13 | + |
| 14 | +/** |
| 15 | + * Initialization and configuration entry point for the Stetho debugging system. Simple usage with |
| 16 | + * default plugins and features enabled: |
| 17 | + * <p/> |
| 18 | + * <pre> |
| 19 | + * Stetho.initializeWithDefaults(context) |
| 20 | + * </pre> |
| 21 | + * <p/> |
| 22 | + * For more advanced configuration, see {@link #newInitializerBuilder(Context)} or |
| 23 | + * the {@code stetho-sample} for more information. |
| 24 | + */ |
| 25 | +public class Stetho { |
| 26 | + private Stetho() { |
| 27 | + } |
| 28 | + |
| 29 | + public static InitializerBuilder newInitializerBuilder(Context context) { |
| 30 | + return new InitializerBuilder(context); |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 34 | + * Start the listening server. Most of the heavy lifting initialization is deferred until the |
| 35 | + * first socket connection is received, allowing this to be safely used for debug builds on |
| 36 | + * even low-end hardware without noticeably affecting performance. |
| 37 | + */ |
| 38 | + public static void initializeWithDefaults(final Context context) { |
| 39 | + |
| 40 | + } |
| 41 | + |
| 42 | + /** |
| 43 | + * Start the listening service, providing a custom initializer as per |
| 44 | + * {@link #newInitializerBuilder}. |
| 45 | + * |
| 46 | + * @see #initializeWithDefaults(Context) |
| 47 | + */ |
| 48 | + public static void initialize(final Initializer initializer) { |
| 49 | + |
| 50 | + } |
| 51 | + |
| 52 | + public static DumperPluginsProvider defaultDumperPluginsProvider(final Context context) { |
| 53 | + return null; |
| 54 | + } |
| 55 | + |
| 56 | + public static InspectorModulesProvider defaultInspectorModulesProvider(final Context context) { |
| 57 | + return null; |
| 58 | + } |
| 59 | + |
| 60 | + /** |
| 61 | + * Callers can choose to subclass this directly to provide the initialization configuration |
| 62 | + * or they can construct a concrete instance using {@link #newInitializerBuilder(Context)}. |
| 63 | + */ |
| 64 | + public abstract static class Initializer { |
| 65 | + |
| 66 | + } |
| 67 | + |
| 68 | + /** |
| 69 | + * Configure what services are to be enabled in this instance of Stetho. |
| 70 | + */ |
| 71 | + public static class InitializerBuilder { |
| 72 | + final Context mContext; |
| 73 | + |
| 74 | + private InitializerBuilder(Context context) { |
| 75 | + mContext = context.getApplicationContext(); |
| 76 | + } |
| 77 | + |
| 78 | + |
| 79 | + public InitializerBuilder enableDumpapp(DumperPluginsProvider plugins) { |
| 80 | + return this; |
| 81 | + } |
| 82 | + |
| 83 | + public InitializerBuilder enableWebKitInspector(InspectorModulesProvider modules) { |
| 84 | + return this; |
| 85 | + } |
| 86 | + |
| 87 | + public Initializer build() { |
| 88 | + return new Initializer() { |
| 89 | + }; |
| 90 | + } |
| 91 | + } |
| 92 | + |
| 93 | +} |
0 commit comments