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 #include "content_frame.h" | |
|
jam
2011/12/22 20:06:53
nit: full path
| |
| 6 | |
| 7 #include "content/browser/frame_map.h" | |
| 8 #include "content/browser/renderer_host/render_view_host.h" | |
| 9 #include "content/public/browser/browser_context.h" | |
| 10 | |
| 11 namespace content { | |
| 12 | |
| 13 ContentFrame::WebKitFrameIdTuple::WebKitFrameIdTuple(int proc_host_id, | |
| 14 int route_id, | |
| 15 int64 frame_id) | |
| 16 : process_host_id(proc_host_id), | |
| 17 route_id(route_id), | |
| 18 frame_id(frame_id) { | |
| 19 } | |
| 20 | |
| 21 bool ContentFrame::WebKitFrameIdTuple::operator==( | |
| 22 const WebKitFrameIdTuple& o) const { | |
|
awong
2011/12/21 01:06:38
single letter variable names are frowned upon.
| |
| 23 return o.process_host_id == process_host_id && | |
| 24 o.frame_id == frame_id; | |
| 25 } | |
| 26 | |
| 27 ContentFrame::ContentFrame(int64 id, | |
| 28 bool is_top_level, | |
| 29 TabContents& tab_contents, | |
| 30 ContentFrame* opener) | |
| 31 : id_(id), | |
| 32 current_webkit_frame_(WebKitFrameIdTuple(-1, -1, -1)), | |
| 33 is_top_level_(is_top_level), | |
| 34 tab_contents_(tab_contents), | |
| 35 opener_(opener) { | |
| 36 if (is_top_level) | |
| 37 new Observer(this); | |
|
awong
2011/12/21 01:06:38
Doesn't this leak?
I think you need to keep the O
| |
| 38 } | |
| 39 | |
| 40 ContentFrame::~ContentFrame() { | |
| 41 } | |
| 42 | |
| 43 void ContentFrame::UpdateFrame(int new_process_host_id, | |
| 44 int new_route_id, | |
| 45 int64 new_frame_id) { | |
| 46 WebKitFrameIdTuple newWebKitTuple(new_process_host_id, new_route_id, | |
|
awong
2011/12/21 01:06:38
local variables are lowercase_with_underscores.
h
| |
| 47 new_frame_id); | |
| 48 current_webkit_frame_ = newWebKitTuple; | |
| 49 | |
| 50 all_webkit_frames_.push_back(newWebKitTuple); | |
| 51 // TODO(supersat): Clear out subframes? | |
|
awong
2011/12/21 01:06:38
Explain why?
| |
| 52 } | |
| 53 | |
| 54 ContentFrame::Observer::Observer( | |
|
awong
2011/12/21 01:06:38
Can be on one line.
| |
| 55 ContentFrame* frame) | |
| 56 : TabContentsObserver(&frame->tab_contents()), | |
| 57 frame_(frame) { | |
| 58 } | |
| 59 | |
| 60 void ContentFrame::Observer::DidCommitProvisionalLoadForFrame( | |
| 61 int64 frame_id, | |
| 62 bool is_main_frame, | |
| 63 const GURL& url, | |
| 64 content::PageTransition transition_type) { | |
| 65 content::FrameMap& mapper = | |
| 66 frame_->tab_contents_.browser_context()->frame_mapper(); | |
| 67 | |
| 68 DLOG(WARNING) << "Navigating frame, Process = " | |
| 69 << frame_->tab_contents_.render_view_host()->process()->GetID() | |
| 70 << ", Renderer = " | |
| 71 << frame_->tab_contents_.render_view_host()->routing_id() | |
| 72 << ", frame = " << frame_id; | |
| 73 | |
| 74 if (is_main_frame) { | |
| 75 mapper.UpdateFrame( | |
| 76 frame_, frame_->tab_contents_.render_view_host()->process()->GetID(), | |
| 77 frame_->tab_contents_.render_view_host()->routing_id(), frame_id); | |
| 78 DLOG(WARNING) << "Content Frame ID = " << frame_->id(); | |
| 79 } else { | |
| 80 // If we're navigating a subframe, we may need to create a ContentFrame | |
| 81 // TODO(supersat): This is hack until we get proper subframe support | |
| 82 ContentFrame* frame = mapper.FindRendererFrame( | |
| 83 frame_->tab_contents_.render_view_host()->process()->GetID(), | |
| 84 frame_id); | |
| 85 | |
| 86 if (!frame) { | |
| 87 frame = mapper.InitializeFrame(mapper.AllocateFrameId(), false, | |
| 88 frame_->tab_contents_, frame_); | |
| 89 mapper.UpdateFrame(frame, | |
| 90 frame_->tab_contents_.render_view_host()->process()->GetID(), | |
| 91 frame_->tab_contents_.render_view_host()->routing_id(), | |
| 92 frame_id); | |
| 93 } | |
| 94 | |
| 95 DLOG(WARNING) << "Content Frame ID = " << frame->id(); | |
| 96 } | |
| 97 } | |
| 98 | |
| 99 void ContentFrame::Observer::TabContentsDestroyed(TabContents* tab) { | |
| 100 delete this; | |
|
awong
2011/12/21 01:56:07
Ah, I see why there is no leak.
Would it make mor
| |
| 101 } | |
| 102 | |
| 103 } // namespace content | |
| OLD | NEW |