Chromium Code Reviews| 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..eb1602fc4d9418c84813722772a0a5f917d76c4f |
| --- /dev/null |
| +++ b/android_webview/native/aw_contents_io_thread_delegate.h |
| @@ -0,0 +1,71 @@ |
| +// 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; |
| +class JavaDelegateMapMaintainer; |
| + |
| +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. |
| +// In that case the instance methods will noop and return default/null values. |
| +class AwWebContentsIoThreadDelegate { |
|
joth
2012/09/11 02:06:50
OK getting my head around this now.
I think futur
mkosiba (inactive)
2012/09/13 01:48:26
added some comments
|
| + public: |
| + // This will attempt to fetch the AwWebContentsIoThreadDelegate for the given |
| + // |render_process_id|, |render_view_id| pair. |
| + // This method can be called from any thread. |
| + // An empty scoped_ptr is a valid return value. |
| + static scoped_ptr<AwWebContentsIoThreadDelegate> |
| + FromID(int render_process_id, int render_view_id); |
| + |
| + static bool RegisterAwWebContentsIoThreadDelegate(JNIEnv* env); |
| + |
| + // This method is called on the IO thread only. |
| + scoped_ptr<InterceptedRequestData> ShouldInterceptRequest( |
| + const net::URLRequest* request); |
| + |
| + ~AwWebContentsIoThreadDelegate(); |
| + |
| + private: |
| + friend class JavaDelegateMapMaintainer; |
| + |
| + AwWebContentsIoThreadDelegate(const base::android::JavaRef<jobject>& obj); |
| + |
| + // This method is called on the UI thread only. |
| + void OnWebContentsDestroyed(); |
| + |
| + base::android::ScopedJavaGlobalRef<jobject> java_object_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AwWebContentsIoThreadDelegate); |
| +}; |
| + |
| +#endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_IO_THREAD_DELEGATE_H_ |