Chromium Code Reviews| Index: content/browser/frame_map.cc |
| diff --git a/content/browser/frame_map.cc b/content/browser/frame_map.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..917327381e3d9792aaf431afb37138c7fe75bc97 |
| --- /dev/null |
| +++ b/content/browser/frame_map.cc |
| @@ -0,0 +1,89 @@ |
| +// Copyright 2011 Google Inc. All Rights Reserved. |
| +// Author: supersat@google.com (Karl Koscher) |
| + |
| +#include "frame_map.h" |
| +#include "browsing_instance_frame_id.h" |
| +#include "base/logging.h" |
| + |
| +namespace content { |
| + |
| +FrameMap::FrameMap() { |
| +} |
| + |
| +FrameMap::~FrameMap() { |
| +} |
| + |
| +int64 FrameMap::AllocateFrameId() { |
| + return next_frame_id_.GetNext() + 1; |
| +} |
| + |
| +BrowsingInstanceFrame* FrameMap::InitializeFrameId(int64 frame_id, |
| + bool is_top_level) { |
|
Charlie Reis
2011/12/12 22:20:36
Indent wrong here and below.
supersat
2011/12/15 19:30:49
Done.
|
| + BrowsingInstanceFrame* frameId = new BrowsingInstanceFrame(frame_id, |
| + is_top_level); |
| + frame_id_map_.insert( |
| + std::pair<int64, BrowsingInstanceFrame*>(frameId->id(), frameId)); |
| + return frameId; |
| +} |
| + |
| +BrowsingInstanceFrame* FrameMap::AllocateNewTopLevelFrameId() { |
| + return InitializeFrameId(AllocateFrameId(), true); |
| +} |
| + |
| +BrowsingInstanceFrame* FrameMap::FindById(int64 id) { |
| + return frame_id_map_[id]; |
| +} |
| + |
| +BrowsingInstanceFrame *FrameMap::FindByWebKitId(int render_process_host_id, |
| + int64 frame_id) { |
| + BrowsingInstanceFrame::WebKitFrameIdTuple webkitFrameId( |
| + render_process_host_id, frame_id); |
| + |
| + BrowsingInstanceFrame* retVal = webkit_frame_id_map_[webkitFrameId]; |
| + DCHECK(retVal); |
| + return retVal; |
| +} |
| + |
| +BrowsingInstanceFrame* FrameMap::FindTopLevelFrameByProcessAndRoute(int process_id, |
| + int route_id) { |
| + // TODO(supersat): Make this significantly less hacky |
| + FrameIdMap::iterator iter; |
| + for (iter = frame_id_map_.begin(); iter != frame_id_map_.end(); iter++) { |
| + BrowsingInstanceFrame* iterFrame = (*iter).second; |
| + if (iterFrame->current_process_host_id() == process_id && |
| + iterFrame->current_route_id() == route_id && |
| + iterFrame->is_top_level()) { |
| + return iterFrame; |
| + } |
| + } |
| + |
| + return 0; |
| +} |
| + |
| +void FrameMap::UpdateFrame(BrowsingInstanceFrame* frame, |
| + int render_process_host_id, |
| + int route_id, |
| + int64 frame_id) { |
| + DLOG(WARNING) << "Calling UpdateFrame: " << |
| + render_process_host_id << ", " << route_id << ", " << |
| + frame_id; |
| + |
| + DCHECK(frame); |
| + BrowsingInstanceFrame::WebKitFrameIdTuple webkitFrameId( |
| + render_process_host_id, frame_id); |
| + frame->current_webkit_frame_ = webkitFrameId; |
| + frame->current_route_id_ = route_id; |
| + webkit_frame_id_map_.insert( |
| + std::pair<BrowsingInstanceFrame::WebKitFrameIdTuple, |
| + BrowsingInstanceFrame*>(webkitFrameId, frame)); |
| +} |
| + |
| +void FrameMap::RemoveFrame(BrowsingInstanceFrame* frame) |
| +{ |
|
Charlie Reis
2011/12/12 22:20:36
Brace on previous line.
|
| + DLOG(WARNING) << "Calling RemoveFrame"; |
| + // TODO(supersat): Remove child frames when they're supported |
| + frame_id_map_.erase(frame->id()); |
| + webkit_frame_id_map_.erase(frame->current_webkit_frame()); |
| +} |
| + |
| +} // namespace content |