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

Unified Diff: content/browser/frame_map.cc

Issue 8760024: Cross-process postMessage (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Current checkpoint Created 9 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/frame_map.h ('k') | content/browser/renderer_host/render_process_host_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9b035a740d287d6e055f819101951a8b50b65df1
--- /dev/null
+++ b/content/browser/frame_map.cc
@@ -0,0 +1,100 @@
+// Copyright (c) 2011 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.
+
+#include "content/browser/frame_map.h"
+
+#include "base/logging.h"
+#include "content/browser/content_frame.h"
+#include "content/browser/renderer_host/render_view_host.h"
+#include "content/browser/webkit_frame_identifier.h"
+#include "content/common/view_messages.h"
+
+namespace content {
+
+FrameMap::FrameMap()
+ : next_frame_id_(0) {
+}
+
+FrameMap::~FrameMap() {
+}
+
+ContentFrame* FrameMap::InitializeFrame(bool is_top_level,
+ TabContents& tab_contents,
+ ContentFrame* opener) {
+ ContentFrame* frame = new ContentFrame(++next_frame_id_, is_top_level,
+ tab_contents, opener);
+ DCHECK(frame);
+ frame_id_map_.insert(
+ std::pair<int64, ContentFrame*>(frame->id(), frame));
+ return frame;
+}
+
+ContentFrame* FrameMap::FindFrame(int64 id) {
+ return frame_id_map_[id];
+}
+
+ContentFrame *FrameMap::FindRendererFrame(int render_process_host_id,
+ int64 frame_id) {
+ WebKitFrameIdentifier webkitFrameId(render_process_host_id, -1, frame_id);
+
+ WebKitFrameIdMap::iterator iter = webkit_frame_id_map_.find(webkitFrameId);
+ if (iter != webkit_frame_id_map_.end())
+ return iter->second;
+ else
+ return NULL;
+}
+
+ContentFrame* FrameMap::FindTopLevelFrame(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++) {
+ ContentFrame* iterFrame = (*iter).second;
+ const WebKitFrameIdentifier webkitFrame = iterFrame->active_webkit_frame();
+ if (webkitFrame.process_host_id == process_id &&
+ webkitFrame.route_id == route_id &&
+ iterFrame->is_top_level()) {
+ return iterFrame;
+ }
+ }
+
+ return 0;
+}
+
+void FrameMap::UpdateFrame(ContentFrame* frame,
+ int render_process_host_id,
+ int route_id,
+ int64 frame_id) {
+ DCHECK(frame);
+ WebKitFrameIdentifier webkitFrameId(
+ render_process_host_id, route_id, frame_id);
+ frame->active_webkit_frame_ = webkitFrameId;
+ webkit_frame_id_map_.insert(
+ std::pair<WebKitFrameIdentifier,
+ ContentFrame*>(webkitFrameId, frame));
+}
+
+// TODO(supersat): This method might not be needed after all.
+void FrameMap::AddSwappedOutRendererToFrame(ContentFrame* frame,
+ int render_process_host_id,
+ int route_id,
+ int64 frame_id) {
+ WebKitFrameIdentifier webkitFrameId(
+ render_process_host_id, route_id, frame_id);
+ webkit_frame_id_map_.insert(
+ std::pair<WebKitFrameIdentifier,
+ ContentFrame*>(webkitFrameId, frame));
+}
+
+void FrameMap::RemoveFrame(ContentFrame* frame) {
+ // TODO(supersat): Remove child frames when they're supported
+ frame_id_map_.erase(frame->id());
+ const std::list<WebKitFrameIdentifier>& webkit_frames =
+ frame->all_webkit_frames();
+ std::list<WebKitFrameIdentifier>::const_iterator iter;
+ for (iter = webkit_frames.begin(); iter != webkit_frames.end(); iter++) {
+ webkit_frame_id_map_.erase(*iter);
+ }
+}
+
+} // namespace content
« no previous file with comments | « content/browser/frame_map.h ('k') | content/browser/renderer_host/render_process_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698