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 PrerenderHandle::~PrerenderHandle() { | |
13 DCHECK(!contents_); | |
14 } | |
15 | |
16 bool PrerenderHandle::Matches( | |
17 const GURL& url, | |
18 const content::SessionStorageNamespace* session_storage_namespace) const { | |
19 DCHECK(CalledOnValidThread()); | |
20 DCHECK(!IsPending()); | |
21 return contents_->Matches(url, session_storage_namespace); | |
22 } | |
23 | |
24 bool PrerenderHandle::IsPending() const { | |
25 DCHECK(CalledOnValidThread()); | |
26 return !contents_; | |
27 } | |
28 | |
29 bool PrerenderHandle::DidFinishLoading() const { | |
30 DCHECK(CalledOnValidThread()); | |
31 if (IsPending()) | |
32 return false; | |
33 return contents_->has_finished_loading(); | |
34 } | |
35 | |
36 void PrerenderHandle::DecrementClientCount() { | |
37 contents_->DecrementClientCount(); | |
dominich
2012/06/22 15:36:16
Where do we increment the client count?
| |
38 } | |
39 | |
40 PrerenderHandle::PrerenderHandle() : contents_(NULL) { | |
41 } | |
42 | |
43 void PrerenderHandle::AddDuplicate( | |
44 scoped_ptr<PrerenderHandle> new_duplicate_handle) { | |
45 DCHECK(new_duplicate_handle->IsPending()); | |
46 PrerenderHandle* old_duplicate_handle = duplicate_handle_.release(); | |
47 | |
48 new_duplicate_handle->contents_ = contents_; | |
49 new_duplicate_handle->duplicate_handle_.reset(old_duplicate_handle); | |
50 duplicate_handle_.swap(new_duplicate_handle); | |
51 } | |
52 | |
53 void PrerenderHandle::SetContents(PrerenderContents* contents) { | |
54 contents_ = contents; | |
55 if (duplicate_handle_.get()) | |
56 duplicate_handle_->SetContents(contents); | |
57 } | |
58 | |
59 } // namespace prerender | |
OLD | NEW |