Save errno for logging before potentially overwriting it.
[chromium-blink-merge.git] / content / public / browser / render_view_host_observer.cc
blobf421bc3a3c7dc18f2eacf04752ad3d3a0b34eeaf
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.
5 #include "content/public/browser/render_view_host_observer.h"
7 #include "content/browser/renderer_host/render_view_host_impl.h"
9 namespace content {
11 RenderViewHostObserver::RenderViewHostObserver(RenderViewHost* render_view_host)
12 : render_view_host_(static_cast<RenderViewHostImpl*>(render_view_host)),
13 routing_id_(render_view_host_->GetRoutingID()) {
14 render_view_host_->AddObserver(this);
17 RenderViewHostObserver::~RenderViewHostObserver() {
18 if (render_view_host_)
19 render_view_host_->RemoveObserver(this);
22 void RenderViewHostObserver::RenderViewHostInitialized() {
25 void RenderViewHostObserver::RenderViewHostDestroyed(RenderViewHost* rvh) {
26 delete this;
29 void RenderViewHostObserver::Navigate(const GURL& url) {
32 bool RenderViewHostObserver::OnMessageReceived(const IPC::Message& message) {
33 return false;
36 bool RenderViewHostObserver::Send(IPC::Message* message) {
37 if (!render_view_host_) {
38 delete message;
39 return false;
42 return render_view_host_->Send(message);
45 RenderViewHost* RenderViewHostObserver::render_view_host() const {
46 return render_view_host_;
49 void RenderViewHostObserver::RenderViewHostDestruction() {
50 render_view_host_->RemoveObserver(this);
51 RenderViewHost* rvh = render_view_host_;
52 render_view_host_ = NULL;
53 RenderViewHostDestroyed(rvh);
56 } // namespace content