Java 类com.facebook.stetho.inspector.helper.ChromePeerManager 实例源码

项目:stetho    文件:ResponseHandlingInputStream.java   
/**
 * @param inputStream
 * @param requestId the requestId to use when we call the {@link NetworkEventReporter}
 * @param outputStream stream to write to.
 * @param decompressedCounter Optional decompressing counting output stream which
 *     can be queried after each write to determine the number of decompressed bytes
 *     yielded.  Used to implement {@link ResponseHandler#onReadDecoded(int)}.
 * @param networkPeerManager A peer manager which is used to log internal errors to the
 *     Inspector console.
 * @param responseHandler Special interface to intercept read events before they are sent
 *     to peers via {@link NetworkEventReporter} methods.
 */
public ResponseHandlingInputStream(
    InputStream inputStream,
    String requestId,
    OutputStream outputStream,
    @Nullable CountingOutputStream decompressedCounter,
    ChromePeerManager networkPeerManager,
    ResponseHandler responseHandler) {
  super(inputStream);
  mRequestId = requestId;
  mOutputStream = outputStream;
  mDecompressedCounter = decompressedCounter;
  mNetworkPeerManager = networkPeerManager;
  mResponseHandler = responseHandler;
  mClosed = false;
}
项目:stetho    文件:CLog.java   
public static void writeToConsole(
    ChromePeerManager chromePeerManager,
    Console.MessageLevel logLevel,
    Console.MessageSource messageSource,
    String messageText) {
  // Send to logcat to increase the chances that a developer will notice :)
  LogRedirector.d(TAG, messageText);

  Console.ConsoleMessage message = new Console.ConsoleMessage();
  message.source = messageSource;
  message.level = logLevel;
  message.text = messageText;
  Console.MessageAddedRequest messageAddedRequest = new Console.MessageAddedRequest();
  messageAddedRequest.message = message;
  chromePeerManager.sendNotificationToPeers("Console.messageAdded", messageAddedRequest);
}
项目:stetho    文件:ResponseHandlingInputStreamTest.java   
@Test
public void testReadOneByte() throws IOException {
  int result = mResponseHandlingInputStream.read();
  assertEquals(TEST_RESPONSE_BODY[0], positionToByte(result));
  assertBufferMatchesResponseBody(mTestOutputStream.toByteArray(), 1);

  PowerMockito.mockStatic(CLog.class);
  PowerMockito.doNothing().when(CLog.class);
  CLog.writeToConsole(
      Mockito.any(ChromePeerManager.class),
      Mockito.any(Console.MessageLevel.class),
      Mockito.any(Console.MessageSource.class),
      Mockito.anyString());
  mResponseHandlingInputStream.close();
  PowerMockito.verifyStatic();
}
项目:stetho    文件:ResponseHandlingInputStreamTest.java   
@Test
public void testReadPartial() throws IOException {
  int numBytesToRead = TEST_RESPONSE_BODY.length / 2;
  byte[] tempReadingBuffer = new byte[numBytesToRead];
  int result = mResponseHandlingInputStream.read(tempReadingBuffer, 0, numBytesToRead);
  assertEquals(numBytesToRead, result);
  assertBufferMatchesResponseBody(tempReadingBuffer, numBytesToRead);
  assertBufferMatchesResponseBody(mTestOutputStream.toByteArray(), numBytesToRead);

  PowerMockito.mockStatic(CLog.class);
  PowerMockito.doNothing().when(CLog.class);
  CLog.writeToConsole(
      Mockito.any(ChromePeerManager.class),
      Mockito.any(Console.MessageLevel.class),
      Mockito.any(Console.MessageSource.class),
      Mockito.anyString());
  mResponseHandlingInputStream.close();
  PowerMockito.verifyStatic();
}
项目:stetho    文件:ResponseHandlingInputStreamTest.java   
@Test
public void testSkipFew() throws IOException {
  long numBytesToSkip = TEST_RESPONSE_BODY.length / 2;
  long result = mResponseHandlingInputStream.skip(numBytesToSkip);
  assertEquals(numBytesToSkip, result);
  assertBufferMatchesResponseBody(mTestOutputStream.toByteArray(), (int) numBytesToSkip);

  PowerMockito.mockStatic(CLog.class);
  PowerMockito.doNothing().when(CLog.class);
  CLog.writeToConsole(
      Mockito.any(ChromePeerManager.class),
      Mockito.any(Console.MessageLevel.class),
      Mockito.any(Console.MessageSource.class),
      Mockito.anyString());
  mResponseHandlingInputStream.close();
  PowerMockito.verifyStatic();
}
项目:stetho    文件:DOM.java   
public DOM(Document document) {
  mObjectMapper = new ObjectMapper();
  mDocument = Util.throwIfNull(document);
  mSearchResults = Collections.synchronizedMap(
    new HashMap<String, List<Integer>>());
  mResultCounter = new AtomicInteger(0);
  mPeerManager = new ChromePeerManager();
  mPeerManager.setListener(new PeerManagerListener());
  mListener = new DocumentUpdateListener();
}
项目:stetho    文件:Database.java   
/**
 * Constructs the object.
 */
public Database() {
  mDatabaseDrivers = new ArrayList<>();
  mChromePeerManager = new ChromePeerManager();
  mPeerListener = new DatabasePeerRegistrationListener(mDatabaseDrivers);
  mChromePeerManager.setListener(mPeerListener);
  mObjectMapper = new ObjectMapper();
}
项目:stetho    文件:CSS.java   
public CSS(Document document) {
  mDocument = Util.throwIfNull(document);
  mObjectMapper = new ObjectMapper();
  mPeerManager = new ChromePeerManager();
  mPeerManager.setListener(new PeerManagerListener());
}