OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/internal_document_state_data.h" | 5 #include "content/renderer/internal_document_state_data.h" |
6 | 6 |
| 7 #include "base/memory/ptr_util.h" |
7 #include "content/public/renderer/document_state.h" | 8 #include "content/public/renderer/document_state.h" |
8 #include "third_party/WebKit/public/web/WebDataSource.h" | 9 #include "third_party/WebKit/public/web/WebDataSource.h" |
9 | 10 |
10 namespace content { | 11 namespace content { |
11 | 12 |
12 namespace { | 13 namespace { |
13 | 14 |
14 // Key InternalDocumentStateData is stored under in DocumentState. | 15 // Key InternalDocumentStateData is stored under in DocumentState. |
15 const char kUserDataKey[] = "InternalDocumentStateData"; | 16 const char kUserDataKey[] = "InternalDocumentStateData"; |
16 | 17 |
(...skipping 14 matching lines...) Expand all Loading... |
31 | 32 |
32 // static | 33 // static |
33 InternalDocumentStateData* InternalDocumentStateData::FromDocumentState( | 34 InternalDocumentStateData* InternalDocumentStateData::FromDocumentState( |
34 DocumentState* ds) { | 35 DocumentState* ds) { |
35 if (!ds) | 36 if (!ds) |
36 return NULL; | 37 return NULL; |
37 InternalDocumentStateData* data = static_cast<InternalDocumentStateData*>( | 38 InternalDocumentStateData* data = static_cast<InternalDocumentStateData*>( |
38 ds->GetUserData(&kUserDataKey)); | 39 ds->GetUserData(&kUserDataKey)); |
39 if (!data) { | 40 if (!data) { |
40 data = new InternalDocumentStateData; | 41 data = new InternalDocumentStateData; |
41 ds->SetUserData(&kUserDataKey, data); | 42 ds->SetUserData(&kUserDataKey, base::WrapUnique(data)); |
42 } | 43 } |
43 return data; | 44 return data; |
44 } | 45 } |
45 | 46 |
46 InternalDocumentStateData::~InternalDocumentStateData() { | 47 InternalDocumentStateData::~InternalDocumentStateData() { |
47 } | 48 } |
48 | 49 |
49 } // namespace content | 50 } // namespace content |
OLD | NEW |