Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 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 CONTENT_BROWSER_CONTENT_FRAME_H_ | |
| 6 #define CONTENT_BROWSER_CONTENT_FRAME_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/hash_tables.h" | |
| 10 #include "content/browser/tab_contents/tab_contents.h" | |
| 11 #include "content/browser/tab_contents/tab_contents_observer.h" | |
| 12 #include <list> | |
|
awong
2011/12/21 01:06:38
C++ includes go first. Separate by a newline.
supersat
2011/12/23 03:22:46
Done.
| |
| 13 | |
| 14 namespace content { | |
|
awong
2011/12/21 01:06:38
newline after namespace opener.
supersat
2011/12/23 03:22:46
Done.
| |
| 15 class FrameMap; | |
| 16 | |
| 17 // This class represents a single user-visible frame and tracks all of the | |
| 18 // (potentially invisible) WebKit frames that may either be currently rendering | |
| 19 // the frame or are proxies for the frame. In conjunction with the FrameMap, | |
| 20 // this is used to route cross-process scripting calls from a proxy WebKit frame | |
| 21 // to the WebKit frame that's currently active. | |
|
awong
2011/12/21 01:06:38
For single class files, It's generally preferable
jam
2011/12/22 20:06:53
really? i didn't know that.
the style is to actua
awong
2011/12/22 20:09:04
Yes...Karl and I talked about this and I was mista
supersat
2011/12/23 03:22:46
Discussed offline. Agreed that keeping the comment
| |
| 22 class ContentFrame { | |
|
jam
2011/12/22 20:06:53
I'm curious why you picked ContentFrame? I ask bec
Charlie Reis
2011/12/22 20:13:21
Wouldn't that imply that there's a RenderFrame it'
| |
| 23 friend class FrameMap; | |
|
awong
2011/12/21 01:06:38
Ick. friends. I don't like friends. That's probabl
supersat
2011/12/23 03:22:46
Everyone seems to be hating on friends, so I'll re
| |
| 24 | |
| 25 public: | |
| 26 // TODO(supersat): Comment this once I figure out exactly what it'll contain | |
|
awong
2011/12/21 01:06:38
Can we pull this out into the content namespace?
jam
2011/12/22 20:06:53
nit: we try to avoid nested classes per the style
supersat
2011/12/23 03:22:46
Done.
| |
| 27 struct WebKitFrameIdTuple { | |
|
awong
2011/12/21 01:06:38
Assuming this doesn't get fragmented/renamed into
jam
2011/12/22 20:06:53
+1
supersat
2011/12/23 03:22:46
Done.
| |
| 28 WebKitFrameIdTuple(int process_host_id, int route_id, int64 frame_id); | |
| 29 | |
| 30 // The == operator does NOT compare the route_id! | |
|
awong
2011/12/21 01:06:38
Is it possible to pull route_id out of this struct
| |
| 31 bool operator==(const WebKitFrameIdTuple& other) const; | |
|
awong
2011/12/21 01:06:38
Chromium style does not allow operator overloading
| |
| 32 | |
| 33 int process_host_id; | |
| 34 int route_id; | |
| 35 int64 frame_id; | |
|
jam
2011/12/22 20:06:53
why use 64 bit numbers for frame id? 32bit is fine
supersat
2011/12/23 03:22:46
WebFrame's identifier is 64-bit. I'm not sure why
| |
| 36 }; | |
| 37 | |
| 38 ContentFrame(int64 id, | |
| 39 bool is_top_level, | |
| 40 TabContents& tab_contents, | |
| 41 ContentFrame* opener); | |
| 42 virtual ~ContentFrame(); | |
|
awong
2011/12/21 01:06:38
No methods are virtual. Why is the destructor vir
supersat
2011/12/23 03:22:46
Done.
| |
| 43 | |
| 44 // Returns the frame's globally-unique identifier. | |
| 45 int64 id() { return id_; } | |
| 46 | |
| 47 // Returns the WebKitFrameIdTuple that uniquely identifies the WebKit frame | |
| 48 // that is actively rendering this frame. | |
| 49 const WebKitFrameIdTuple current_webkit_frame() const { | |
|
awong
2011/12/21 01:06:38
What do you think about "active" instead of "curre
supersat
2011/12/23 03:22:46
Done.
| |
| 50 return current_webkit_frame_; | |
| 51 } | |
| 52 | |
| 53 // Returns the process id for the WebKit frame that's actively rendering this | |
| 54 // frame. | |
|
awong
2011/12/21 01:06:38
These are duplicate accessors for data that can be
supersat
2011/12/23 03:22:46
Done.
| |
| 55 int current_process_host_id() const { | |
| 56 return current_webkit_frame_.process_host_id; | |
| 57 } | |
| 58 | |
| 59 // Returns the RenderView route id for the WebKit frame that's actively | |
| 60 // rendering this frame. | |
| 61 int current_route_id() const { | |
| 62 return current_webkit_frame_.route_id; | |
| 63 } | |
| 64 | |
| 65 // Returns the WebKit frame id for the WebKit frame that's actively rendering | |
| 66 // this frame. Note that the WebKit frame id is only unique per-process! | |
|
awong
2011/12/21 01:06:38
http://google-styleguide.googlecode.com/svn/trunk/
| |
| 67 int64 current_frame_id() const { | |
| 68 return current_webkit_frame_.frame_id; | |
| 69 } | |
| 70 | |
| 71 // Returns whether this frame is a top-level frame or not. Each RenderView and | |
| 72 // TabContents has one top-level frame. | |
| 73 bool is_top_level() const { | |
| 74 return is_top_level_; | |
| 75 } | |
| 76 | |
| 77 // Returns the RenderViewHostDelegate for this frame. | |
| 78 TabContents& tab_contents() const { | |
| 79 return tab_contents_; | |
| 80 } | |
| 81 | |
| 82 // Returns a list of all WebKit frames that are either rendering this frame or | |
| 83 // are proxies for this frame. | |
| 84 const std::list<WebKitFrameIdTuple> all_webkit_frames() const { | |
|
awong
2011/12/21 01:06:38
const&?
| |
| 85 return all_webkit_frames_; | |
| 86 } | |
| 87 | |
| 88 // Updates which WebKit frame is currently rendering this frame. | |
| 89 void UpdateFrame(int new_process_host_id, | |
|
awong
2011/12/21 01:06:38
How about SetActiveFrame() or ReplaceActiveFrame()
| |
| 90 int new_route_id, | |
| 91 int64 new_frame_id); | |
| 92 | |
| 93 // Return this ContentFrame's opener. | |
| 94 ContentFrame* opener() const { | |
| 95 return opener_; | |
| 96 } | |
| 97 | |
| 98 private: | |
| 99 class Observer : public TabContentsObserver { | |
|
jam
2011/12/22 20:06:53
nit: this class is an internal implementation and
| |
| 100 public: | |
| 101 Observer(ContentFrame* frame); | |
|
awong
2011/12/21 01:06:38
explicit.
http://google-styleguide.googlecode.com
| |
| 102 // TabContentsObserver methods | |
| 103 virtual void DidCommitProvisionalLoadForFrame( | |
| 104 int64 frame_id, | |
| 105 bool is_main_frame, | |
| 106 const GURL& url, | |
| 107 content::PageTransition transition_type) OVERRIDE; | |
| 108 | |
| 109 virtual void TabContentsDestroyed(TabContents* tab) OVERRIDE; | |
| 110 | |
| 111 private: | |
| 112 ContentFrame* frame_; | |
| 113 }; | |
| 114 | |
| 115 int64 id_; | |
| 116 | |
| 117 WebKitFrameIdTuple current_webkit_frame_; | |
| 118 bool is_top_level_; | |
| 119 | |
| 120 std::list<WebKitFrameIdTuple> all_webkit_frames_; | |
| 121 | |
| 122 TabContents& tab_contents_; | |
|
jam
2011/12/22 20:06:53
nit: i've never seen us storing references to TabC
| |
| 123 | |
| 124 ContentFrame* opener_; | |
| 125 }; | |
| 126 | |
| 127 } // namespace content | |
| 128 | |
| 129 #if defined(COMPILER_GCC) | |
| 130 namespace __gnu_cxx { | |
| 131 | |
| 132 // Since the == operator does not compare the route_id, we don't include it in | |
| 133 // the hash. | |
| 134 template<> | |
| 135 struct hash<content::ContentFrame::WebKitFrameIdTuple> { | |
| 136 std::size_t operator()(const | |
|
awong
2011/12/21 01:06:38
bad wrap...
| |
| 137 content::ContentFrame::WebKitFrameIdTuple& p) const { | |
| 138 return p.process_host_id * 257 + p.frame_id; | |
|
awong
2011/12/21 01:06:38
Magic number! Explain?
| |
| 139 } | |
| 140 }; | |
| 141 | |
| 142 } // namespace __gnu_cxx | |
| 143 #endif | |
| 144 | |
| 145 #endif // CONTENT_BROWSER_CONTENT_FRAME_H_ | |
| OLD | NEW |