Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Unified Diff: components/cronet/android/api/src/org/chromium/net/RequestFinishedListener.java

Issue 2178053002: Change RequestFinishedListener to provide executor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: formatting Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/cronet/android/api/src/org/chromium/net/RequestFinishedListener.java
diff --git a/components/cronet/android/api/src/org/chromium/net/RequestFinishedListener.java b/components/cronet/android/api/src/org/chromium/net/RequestFinishedListener.java
new file mode 100644
index 0000000000000000000000000000000000000000..764aa05e6a17e61727d8977109cdd338d2ced103
--- /dev/null
+++ b/components/cronet/android/api/src/org/chromium/net/RequestFinishedListener.java
@@ -0,0 +1,38 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.net;
+
+import java.util.concurrent.Executor;
+
+/**
+ * Listens for finished requests for the purpose of collecting metrics.
+ *
+ * {@hide} as it's a prototype.
+ */
+public abstract class RequestFinishedListener {
+ private final Executor mExecutor;
+
+ public RequestFinishedListener(Executor executor) {
+ if (executor == null) {
+ throw new IllegalStateException("Executor must not be null");
+ }
+ mExecutor = executor;
+ }
+
+ /**
+ * Invoked with request info. Will be called in a task submitted to the
+ * {@link java.util.concurrent.Executor} returned by {@link #getExecutor}.
+ * @param requestInfo {@link CronetEngine#UrlRequestInfo} for finished request.
+ */
+ public abstract void onRequestFinished(CronetEngine.UrlRequestInfo requestInfo);
+
+ /**
+ * Returns this listener's executor. Can be called on any thread.
+ * @return this listener's {@link java.util.concurrent.Executor}
+ */
+ public Executor getExecutor() {
+ return mExecutor;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698