Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 | 30 |
| 31 #include "modules/quota/NavigatorStorageQuota.h" | 31 #include "modules/quota/NavigatorStorageQuota.h" |
| 32 | 32 |
| 33 #include "core/frame/Navigator.h" | 33 #include "core/frame/Navigator.h" |
| 34 #include "modules/quota/DeprecatedStorageQuota.h" | 34 #include "modules/quota/DeprecatedStorageQuota.h" |
| 35 #include "modules/quota/StorageManager.h" | 35 #include "modules/quota/StorageManager.h" |
| 36 #include "modules/quota/StorageQuota.h" | 36 #include "modules/quota/StorageQuota.h" |
| 37 | 37 |
| 38 namespace blink { | 38 namespace blink { |
| 39 | 39 |
| 40 NavigatorStorageQuota::NavigatorStorageQuota(LocalFrame* frame) | 40 NavigatorStorageQuota::NavigatorStorageQuota(Navigator& navigator) |
| 41 : ContextClient(frame) {} | 41 : Supplement<Navigator>(navigator) {} |
| 42 | 42 |
| 43 const char* NavigatorStorageQuota::supplementName() { | 43 const char* NavigatorStorageQuota::supplementName() { |
| 44 return "NavigatorStorageQuota"; | 44 return "NavigatorStorageQuota"; |
| 45 } | 45 } |
| 46 | 46 |
| 47 NavigatorStorageQuota& NavigatorStorageQuota::from(Navigator& navigator) { | 47 NavigatorStorageQuota& NavigatorStorageQuota::from(Navigator& navigator) { |
| 48 NavigatorStorageQuota* supplement = static_cast<NavigatorStorageQuota*>( | 48 NavigatorStorageQuota* supplement = static_cast<NavigatorStorageQuota*>( |
| 49 Supplement<Navigator>::from(navigator, supplementName())); | 49 Supplement<Navigator>::from(navigator, supplementName())); |
| 50 if (!supplement) { | 50 if (!supplement) { |
| 51 supplement = new NavigatorStorageQuota(navigator.frame()); | 51 supplement = new NavigatorStorageQuota(navigator); |
| 52 provideTo(navigator, supplementName(), supplement); | 52 provideTo(navigator, supplementName(), supplement); |
| 53 } | 53 } |
| 54 return *supplement; | 54 return *supplement; |
| 55 } | 55 } |
| 56 | 56 |
| 57 StorageQuota* NavigatorStorageQuota::storageQuota(Navigator& navigator) { | 57 StorageQuota* NavigatorStorageQuota::storageQuota(Navigator& navigator) { |
| 58 return NavigatorStorageQuota::from(navigator).storageQuota(); | 58 return NavigatorStorageQuota::from(navigator).storageQuota(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 DeprecatedStorageQuota* NavigatorStorageQuota::webkitTemporaryStorage( | 61 DeprecatedStorageQuota* NavigatorStorageQuota::webkitTemporaryStorage( |
| 62 Navigator& navigator) { | 62 Navigator& navigator) { |
| 63 return NavigatorStorageQuota::from(navigator).webkitTemporaryStorage(); | 63 return NavigatorStorageQuota::from(navigator).webkitTemporaryStorage(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 DeprecatedStorageQuota* NavigatorStorageQuota::webkitPersistentStorage( | 66 DeprecatedStorageQuota* NavigatorStorageQuota::webkitPersistentStorage( |
| 67 Navigator& navigator) { | 67 Navigator& navigator) { |
| 68 return NavigatorStorageQuota::from(navigator).webkitPersistentStorage(); | 68 return NavigatorStorageQuota::from(navigator).webkitPersistentStorage(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 StorageManager* NavigatorStorageQuota::storage(Navigator& navigator) { | 71 StorageManager* NavigatorStorageQuota::storage(Navigator& navigator) { |
| 72 return NavigatorStorageQuota::from(navigator).storage(); | 72 return NavigatorStorageQuota::from(navigator).storage(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 StorageQuota* NavigatorStorageQuota::storageQuota() const { | 75 StorageQuota* NavigatorStorageQuota::storageQuota() const { |
| 76 if (!m_storageQuota && frame()) | 76 if (!m_storageQuota) |
|
haraken
2017/01/06 01:20:37
These frame() checks won't really make sense, so d
sof
2017/01/06 07:22:54
Looks fine. Digging around in history, it seems li
| |
| 77 m_storageQuota = StorageQuota::create(); | 77 m_storageQuota = StorageQuota::create(); |
| 78 return m_storageQuota.get(); | 78 return m_storageQuota.get(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 DeprecatedStorageQuota* NavigatorStorageQuota::webkitTemporaryStorage() const { | 81 DeprecatedStorageQuota* NavigatorStorageQuota::webkitTemporaryStorage() const { |
| 82 if (!m_temporaryStorage && frame()) | 82 if (!m_temporaryStorage) |
| 83 m_temporaryStorage = | 83 m_temporaryStorage = |
| 84 DeprecatedStorageQuota::create(DeprecatedStorageQuota::Temporary); | 84 DeprecatedStorageQuota::create(DeprecatedStorageQuota::Temporary); |
| 85 return m_temporaryStorage.get(); | 85 return m_temporaryStorage.get(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 DeprecatedStorageQuota* NavigatorStorageQuota::webkitPersistentStorage() const { | 88 DeprecatedStorageQuota* NavigatorStorageQuota::webkitPersistentStorage() const { |
| 89 if (!m_persistentStorage && frame()) | 89 if (!m_persistentStorage) |
| 90 m_persistentStorage = | 90 m_persistentStorage = |
| 91 DeprecatedStorageQuota::create(DeprecatedStorageQuota::Persistent); | 91 DeprecatedStorageQuota::create(DeprecatedStorageQuota::Persistent); |
| 92 return m_persistentStorage.get(); | 92 return m_persistentStorage.get(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 StorageManager* NavigatorStorageQuota::storage() const { | 95 StorageManager* NavigatorStorageQuota::storage() const { |
| 96 if (!m_storageManager && frame()) | 96 if (!m_storageManager) |
| 97 m_storageManager = new StorageManager(); | 97 m_storageManager = new StorageManager(); |
| 98 return m_storageManager.get(); | 98 return m_storageManager.get(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 DEFINE_TRACE(NavigatorStorageQuota) { | 101 DEFINE_TRACE(NavigatorStorageQuota) { |
| 102 visitor->trace(m_storageQuota); | 102 visitor->trace(m_storageQuota); |
| 103 visitor->trace(m_temporaryStorage); | 103 visitor->trace(m_temporaryStorage); |
| 104 visitor->trace(m_persistentStorage); | 104 visitor->trace(m_persistentStorage); |
| 105 visitor->trace(m_storageManager); | 105 visitor->trace(m_storageManager); |
| 106 Supplement<Navigator>::trace(visitor); | 106 Supplement<Navigator>::trace(visitor); |
| 107 ContextClient::trace(visitor); | |
| 108 } | 107 } |
| 109 | 108 |
| 110 } // namespace blink | 109 } // namespace blink |
| OLD | NEW |