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

Side by Side Diff: Source/modules/indexeddb/DOMWindowIndexedDatabase.cpp

Issue 171333003: Pass implementation object to supplemental classes by reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 10 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, Google Inc. All rights reserved. 2 * Copyright (C) 2011, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met: 5 * modification, are permitted provided that the following conditions are met:
6 * 6 *
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 15 matching lines...) Expand all
26 #include "config.h" 26 #include "config.h"
27 #include "modules/indexeddb/DOMWindowIndexedDatabase.h" 27 #include "modules/indexeddb/DOMWindowIndexedDatabase.h"
28 28
29 #include "core/dom/Document.h" 29 #include "core/dom/Document.h"
30 #include "core/frame/DOMWindow.h" 30 #include "core/frame/DOMWindow.h"
31 #include "core/page/Page.h" 31 #include "core/page/Page.h"
32 #include "modules/indexeddb/IDBFactory.h" 32 #include "modules/indexeddb/IDBFactory.h"
33 33
34 namespace WebCore { 34 namespace WebCore {
35 35
36 DOMWindowIndexedDatabase::DOMWindowIndexedDatabase(DOMWindow* window) 36 DOMWindowIndexedDatabase::DOMWindowIndexedDatabase(DOMWindow& window)
37 : DOMWindowProperty(window->frame()) 37 : DOMWindowProperty(window.frame())
38 , m_window(window) 38 , m_window(window)
39 { 39 {
40 } 40 }
41 41
42 DOMWindowIndexedDatabase::~DOMWindowIndexedDatabase() 42 DOMWindowIndexedDatabase::~DOMWindowIndexedDatabase()
43 { 43 {
44 } 44 }
45 45
46 const char* DOMWindowIndexedDatabase::supplementName() 46 const char* DOMWindowIndexedDatabase::supplementName()
47 { 47 {
48 return "DOMWindowIndexedDatabase"; 48 return "DOMWindowIndexedDatabase";
49 } 49 }
50 50
51 DOMWindowIndexedDatabase* DOMWindowIndexedDatabase::from(DOMWindow* window) 51 DOMWindowIndexedDatabase& DOMWindowIndexedDatabase::from(DOMWindow& window)
52 { 52 {
53 DOMWindowIndexedDatabase* supplement = static_cast<DOMWindowIndexedDatabase* >(Supplement<DOMWindow>::from(window, supplementName())); 53 DOMWindowIndexedDatabase* supplement = static_cast<DOMWindowIndexedDatabase* >(Supplement<DOMWindow>::from(window, supplementName()));
54 if (!supplement) { 54 if (!supplement) {
55 supplement = new DOMWindowIndexedDatabase(window); 55 supplement = new DOMWindowIndexedDatabase(window);
56 provideTo(window, supplementName(), adoptPtr(supplement)); 56 provideTo(window, supplementName(), adoptPtr(supplement));
57 } 57 }
58 return supplement; 58 return *supplement;
59 } 59 }
60 60
61 void DOMWindowIndexedDatabase::willDestroyGlobalObjectInFrame() 61 void DOMWindowIndexedDatabase::willDestroyGlobalObjectInFrame()
62 { 62 {
63 m_idbFactory = nullptr; 63 m_idbFactory = nullptr;
64 DOMWindowProperty::willDestroyGlobalObjectInFrame(); 64 DOMWindowProperty::willDestroyGlobalObjectInFrame();
65 } 65 }
66 66
67 void DOMWindowIndexedDatabase::willDetachGlobalObjectFromFrame() 67 void DOMWindowIndexedDatabase::willDetachGlobalObjectFromFrame()
68 { 68 {
69 m_idbFactory = nullptr; 69 m_idbFactory = nullptr;
70 DOMWindowProperty::willDetachGlobalObjectFromFrame(); 70 DOMWindowProperty::willDetachGlobalObjectFromFrame();
71 } 71 }
72 72
73 IDBFactory* DOMWindowIndexedDatabase::indexedDB(DOMWindow* window) 73 IDBFactory* DOMWindowIndexedDatabase::indexedDB(DOMWindow& window)
74 { 74 {
75 return from(window)->indexedDB(); 75 return from(window).indexedDB();
76 } 76 }
77 77
78 IDBFactory* DOMWindowIndexedDatabase::indexedDB() 78 IDBFactory* DOMWindowIndexedDatabase::indexedDB()
79 { 79 {
80 Document* document = m_window->document(); 80 Document* document = m_window.document();
81 if (!document) 81 if (!document)
82 return 0; 82 return 0;
83 83
84 Page* page = document->page(); 84 Page* page = document->page();
85 if (!page) 85 if (!page)
86 return 0; 86 return 0;
87 87
88 if (!m_window->isCurrentlyDisplayedInFrame()) 88 if (!m_window.isCurrentlyDisplayedInFrame())
89 return 0; 89 return 0;
90 90
91 if (!m_idbFactory) 91 if (!m_idbFactory)
92 m_idbFactory = IDBFactory::create(IDBFactoryBackendInterface::create().g et()); 92 m_idbFactory = IDBFactory::create(IDBFactoryBackendInterface::create().g et());
93 return m_idbFactory.get(); 93 return m_idbFactory.get();
94 } 94 }
95 95
96 } // namespace WebCore 96 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698