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

Unified Diff: android_webview/native/aw_contents_io_thread_delegate.h

Issue 10702083: Add ContentViewDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rewritten for the new android_webview folder Created 8 years, 4 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: android_webview/native/aw_contents_io_thread_delegate.h
diff --git a/android_webview/native/aw_contents_io_thread_delegate.h b/android_webview/native/aw_contents_io_thread_delegate.h
new file mode 100644
index 0000000000000000000000000000000000000000..e266773f68086517dc4c62b61eb63d06fb6dc008
--- /dev/null
+++ b/android_webview/native/aw_contents_io_thread_delegate.h
@@ -0,0 +1,73 @@
+// Copyright (c) 2012 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.
+
+#ifndef ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_IO_THREAD_DELEGATE_H_
+#define ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_IO_THREAD_DELEGATE_H_
+
+#include "base/android/scoped_java_ref.h"
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+
+class GURL;
+class InterceptedRequestData;
+
+namespace content {
+class RenderViewHost;
+struct Referrer;
+class WebContents;
+}
+
+namespace net {
+class URLRequest;
+}
+
+// This lets us implement URLRequest intercepting in a way that lets the
+// embedder associate URLRequests with the WebContents that the URLRequest
+// is made for.
+//
+// It is preferable to use the static getter methods to obtain a new instance
+// of the class rather than holding on to one for prolonged periods of time
+// (see note for more details).
+//
+// Note: The native AwWebContentsIoThreadDelegate instance has a Global ref to
+// the Java object. By keeping the native AwWebContentsIoThreadDelegate
+// instance alive you're also prolonging the lifetime of the Java instance, so
+// don't keep a AwWebContentsIoThreadDelegate if you don't need to.
+// It is also possible that AwWebContentsIoThreadDelegate becomes invalid when
+// you're holding on to it. This could happen if the WebContents is destroyed.
joth 2012/09/01 01:24:14 if the WC is destroyed, the AwWebContentsIoThread
mkosiba (inactive) 2012/09/11 01:22:25 the Java side class will exist, but we only make c
+// In that case the instance methods will noop and return default/null values.
+class AwWebContentsIoThreadDelegate {
+ public:
+ // This will attempt to fetch the AwWebContentsIoThreadDelegate for the given
+ // |rvh|.
+ // This method can be called from any thread.
+ // An empty scoped_ptr is a valid return value.
+ static scoped_ptr<AwWebContentsIoThreadDelegate>
+ ForRenderViewHost(content::RenderViewHost* rvh);
joth 2012/09/01 01:24:14 returning scoped_ptr (returning ownership) makes i
mkosiba (inactive) 2012/09/11 01:22:25 it's a bit uncommon but the intent behind this is
+
+ // This will attempt to fetch the AwWebContentsIoThreadDelegate for the given
+ // This method can be called from any thread.
+ // |contents|. An empty scoped_ptr is a valid return value.
+ static scoped_ptr<AwWebContentsIoThreadDelegate>
+ ForWebContents(content::WebContents* contents);
joth 2012/09/01 01:24:14 Can't quite follow the usage model for these witho
mkosiba (inactive) 2012/09/11 01:22:25 yeath.. I'll clean this up. We should be getting t
+
+ static bool RegisterAwWebContentsIoThreadDelegate(JNIEnv* env);
+
+ // This method is called on the IO thread only.
+ scoped_ptr<InterceptedRequestData> ShouldInterceptRequest(
+ const net::URLRequest* request);
+
+ ~AwWebContentsIoThreadDelegate();
+
+ class WebContentsObserver;
joth 2012/09/01 01:24:14 nit: call this something about its job, JavaDelega
mkosiba (inactive) 2012/09/11 01:22:25 Renamed, has to be inner/friend in order to be abl
+ private:
+ DISALLOW_COPY_AND_ASSIGN(AwWebContentsIoThreadDelegate);
joth 2012/09/01 01:24:14 should be last. the WCO forward declaration isn't
mkosiba (inactive) 2012/09/11 01:22:25 Done
+
+ AwWebContentsIoThreadDelegate(const base::android::JavaRef<jobject>& obj);
+ void OnWebContentsDestroyed();
+
+ base::android::ScopedJavaGlobalRef<jobject> java_object_;
+};
+
+#endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_IO_THREAD_DELEGATE_H_

Powered by Google App Engine
This is Rietveld 408576698