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

Side by Side 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: addressed feedback Created 8 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_IO_THREAD_DELEGATE_H_
6 #define ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_IO_THREAD_DELEGATE_H_
7
8 #include "base/android/scoped_java_ref.h"
9 #include "base/basictypes.h"
10 #include "base/memory/scoped_ptr.h"
11
12 class GURL;
13 class InterceptedRequestData;
14 class JavaDelegateMapMaintainer;
15
16 namespace content {
17 class RenderViewHost;
18 struct Referrer;
19 class WebContents;
20 }
21
22 namespace net {
23 class URLRequest;
24 }
25
26 // This lets us implement URLRequest intercepting in a way that lets the
27 // embedder associate URLRequests with the WebContents that the URLRequest
28 // is made for.
29 //
30 // It is preferable to use the static getter methods to obtain a new instance
31 // of the class rather than holding on to one for prolonged periods of time
32 // (see note for more details).
33 //
34 // Note: The native AwWebContentsIoThreadDelegate instance has a Global ref to
35 // the Java object. By keeping the native AwWebContentsIoThreadDelegate
36 // instance alive you're also prolonging the lifetime of the Java instance, so
37 // don't keep a AwWebContentsIoThreadDelegate if you don't need to.
38 // It is also possible that AwWebContentsIoThreadDelegate becomes invalid when
39 // you're holding on to it. This could happen if the WebContents is destroyed.
40 // In that case the instance methods will noop and return default/null values.
41 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
42 public:
43 // This will attempt to fetch the AwWebContentsIoThreadDelegate for the given
44 // |render_process_id|, |render_view_id| pair.
45 // This method can be called from any thread.
46 // An empty scoped_ptr is a valid return value.
47 static scoped_ptr<AwWebContentsIoThreadDelegate>
48 FromID(int render_process_id, int render_view_id);
49
50 static bool RegisterAwWebContentsIoThreadDelegate(JNIEnv* env);
51
52 // This method is called on the IO thread only.
53 scoped_ptr<InterceptedRequestData> ShouldInterceptRequest(
54 const net::URLRequest* request);
55
56 ~AwWebContentsIoThreadDelegate();
57
58 private:
59 friend class JavaDelegateMapMaintainer;
60
61 AwWebContentsIoThreadDelegate(const base::android::JavaRef<jobject>& obj);
62
63 // This method is called on the UI thread only.
64 void OnWebContentsDestroyed();
65
66 base::android::ScopedJavaGlobalRef<jobject> java_object_;
67
68 DISALLOW_COPY_AND_ASSIGN(AwWebContentsIoThreadDelegate);
69 };
70
71 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_IO_THREAD_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698