OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "chrome/browser/prerender/prerender_handle.h" |
| 6 |
| 7 #include "base/basictypes.h" |
| 8 #include "chrome/browser/prerender/prerender_contents.h" |
| 9 |
| 10 namespace prerender { |
| 11 |
| 12 PrerenderHandleImpl::~PrerenderHandleImpl() { |
| 13 } |
| 14 |
| 15 bool PrerenderHandleImpl::IsPending() const { |
| 16 DCHECK(CalledOnValidThread()); |
| 17 return !contents_; |
| 18 } |
| 19 |
| 20 bool PrerenderHandleImpl::DidFinishLoading() const { |
| 21 DCHECK(CalledOnValidThread()); |
| 22 if (IsPending()) |
| 23 return false; |
| 24 return contents_->has_finished_loading(); |
| 25 } |
| 26 |
| 27 void PrerenderHandleImpl::Release() { |
| 28 DVLOG(4) << "PrerenderHandleImpl::Release()"; |
| 29 contents_->DecrementClientCount(); |
| 30 } |
| 31 |
| 32 PrerenderHandleImpl::PrerenderHandleImpl() : contents_(NULL) { |
| 33 } |
| 34 |
| 35 void PrerenderHandleImpl::AddDuplicate( |
| 36 PrerenderHandleImpl* new_duplicate_handle) { |
| 37 DCHECK(new_duplicate_handle->IsPending()); |
| 38 PrerenderHandleImpl* old_duplicate_handle = duplicate_handle_.release(); |
| 39 |
| 40 new_duplicate_handle->contents_ = contents_; |
| 41 new_duplicate_handle->duplicate_handle_.reset(old_duplicate_handle); |
| 42 duplicate_handle_.reset(new_duplicate_handle); |
| 43 |
| 44 contents_->IncrementClientCount(); |
| 45 } |
| 46 |
| 47 void PrerenderHandleImpl::AddClient() { |
| 48 contents_->IncrementClientCount(); |
| 49 } |
| 50 |
| 51 void PrerenderHandleImpl::SetContents(PrerenderContents* contents) { |
| 52 contents_ = contents; |
| 53 if (duplicate_handle_.get()) |
| 54 duplicate_handle_->SetContents(contents); |
| 55 } |
| 56 |
| 57 } // namespace prerender |
OLD | NEW |