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

Side by Side Diff: third_party/WebKit/Source/modules/quota/DeprecatedStorageInfo.cpp

Issue 2700753002: Replace ExecutionContextTask with WTF::Closure in StorageErrorCallback (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/quota/DeprecatedStorageQuota.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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
30 30
31 #include "modules/quota/DeprecatedStorageInfo.h" 31 #include "modules/quota/DeprecatedStorageInfo.h"
32 32
33 #include "bindings/core/v8/ScriptState.h" 33 #include "bindings/core/v8/ScriptState.h"
34 #include "core/dom/ExceptionCode.h" 34 #include "core/dom/ExceptionCode.h"
35 #include "core/dom/TaskRunnerHelper.h" 35 #include "core/dom/TaskRunnerHelper.h"
36 #include "modules/quota/DeprecatedStorageQuota.h" 36 #include "modules/quota/DeprecatedStorageQuota.h"
37 #include "modules/quota/StorageErrorCallback.h" 37 #include "modules/quota/StorageErrorCallback.h"
38 #include "modules/quota/StorageQuotaCallback.h" 38 #include "modules/quota/StorageQuotaCallback.h"
39 #include "modules/quota/StorageUsageCallback.h" 39 #include "modules/quota/StorageUsageCallback.h"
40 #include "platform/WebTaskRunner.h"
40 #include "public/platform/WebTraceLocation.h" 41 #include "public/platform/WebTraceLocation.h"
41 42
42 namespace blink { 43 namespace blink {
43 44
44 DeprecatedStorageInfo::DeprecatedStorageInfo() {} 45 DeprecatedStorageInfo::DeprecatedStorageInfo() {}
45 46
46 void DeprecatedStorageInfo::queryUsageAndQuota( 47 void DeprecatedStorageInfo::queryUsageAndQuota(
47 ScriptState* scriptState, 48 ScriptState* scriptState,
48 int storageType, 49 int storageType,
49 StorageUsageCallback* successCallback, 50 StorageUsageCallback* successCallback,
50 StorageErrorCallback* errorCallback) { 51 StorageErrorCallback* errorCallback) {
51 // Dispatching the request to DeprecatedStorageQuota, as this interface is 52 // Dispatching the request to DeprecatedStorageQuota, as this interface is
52 // deprecated in favor of DeprecatedStorageQuota. 53 // deprecated in favor of DeprecatedStorageQuota.
53 DeprecatedStorageQuota* storageQuota = getStorageQuota(storageType); 54 DeprecatedStorageQuota* storageQuota = getStorageQuota(storageType);
54 if (!storageQuota) { 55 if (!storageQuota) {
55 // Unknown storage type is requested. 56 // Unknown storage type is requested.
56 scriptState->getExecutionContext()->postTask( 57 TaskRunnerHelper::get(TaskType::MiscPlatformAPI,
57 TaskType::MiscPlatformAPI, BLINK_FROM_HERE, 58 scriptState->getExecutionContext())
58 StorageErrorCallback::createSameThreadTask(errorCallback, 59 ->postTask(BLINK_FROM_HERE, StorageErrorCallback::createSameThreadTask(
59 NotSupportedError)); 60 errorCallback, NotSupportedError));
60 return; 61 return;
61 } 62 }
62 storageQuota->queryUsageAndQuota(scriptState, successCallback, errorCallback); 63 storageQuota->queryUsageAndQuota(scriptState, successCallback, errorCallback);
63 } 64 }
64 65
65 void DeprecatedStorageInfo::requestQuota(ScriptState* scriptState, 66 void DeprecatedStorageInfo::requestQuota(ScriptState* scriptState,
66 int storageType, 67 int storageType,
67 unsigned long long newQuotaInBytes, 68 unsigned long long newQuotaInBytes,
68 StorageQuotaCallback* successCallback, 69 StorageQuotaCallback* successCallback,
69 StorageErrorCallback* errorCallback) { 70 StorageErrorCallback* errorCallback) {
70 // Dispatching the request to DeprecatedStorageQuota, as this interface is 71 // Dispatching the request to DeprecatedStorageQuota, as this interface is
71 // deprecated in favor of DeprecatedStorageQuota. 72 // deprecated in favor of DeprecatedStorageQuota.
72 DeprecatedStorageQuota* storageQuota = getStorageQuota(storageType); 73 DeprecatedStorageQuota* storageQuota = getStorageQuota(storageType);
73 if (!storageQuota) { 74 if (!storageQuota) {
74 // Unknown storage type is requested. 75 // Unknown storage type is requested.
75 scriptState->getExecutionContext()->postTask( 76 TaskRunnerHelper::get(TaskType::MiscPlatformAPI,
76 TaskType::MiscPlatformAPI, BLINK_FROM_HERE, 77 scriptState->getExecutionContext())
77 StorageErrorCallback::createSameThreadTask(errorCallback, 78 ->postTask(BLINK_FROM_HERE, StorageErrorCallback::createSameThreadTask(
78 NotSupportedError)); 79 errorCallback, NotSupportedError));
79 return; 80 return;
80 } 81 }
81 storageQuota->requestQuota(scriptState, newQuotaInBytes, successCallback, 82 storageQuota->requestQuota(scriptState, newQuotaInBytes, successCallback,
82 errorCallback); 83 errorCallback);
83 } 84 }
84 85
85 DeprecatedStorageQuota* DeprecatedStorageInfo::getStorageQuota( 86 DeprecatedStorageQuota* DeprecatedStorageInfo::getStorageQuota(
86 int storageType) { 87 int storageType) {
87 switch (storageType) { 88 switch (storageType) {
88 case kTemporary: 89 case kTemporary:
89 if (!m_temporaryStorage) 90 if (!m_temporaryStorage)
90 m_temporaryStorage = 91 m_temporaryStorage =
91 DeprecatedStorageQuota::create(DeprecatedStorageQuota::Temporary); 92 DeprecatedStorageQuota::create(DeprecatedStorageQuota::Temporary);
92 return m_temporaryStorage.get(); 93 return m_temporaryStorage.get();
93 case kPersistent: 94 case kPersistent:
94 if (!m_persistentStorage) 95 if (!m_persistentStorage)
95 m_persistentStorage = 96 m_persistentStorage =
96 DeprecatedStorageQuota::create(DeprecatedStorageQuota::Persistent); 97 DeprecatedStorageQuota::create(DeprecatedStorageQuota::Persistent);
97 return m_persistentStorage.get(); 98 return m_persistentStorage.get();
98 } 99 }
99 return 0; 100 return 0;
100 } 101 }
101 102
102 DEFINE_TRACE(DeprecatedStorageInfo) { 103 DEFINE_TRACE(DeprecatedStorageInfo) {
103 visitor->trace(m_temporaryStorage); 104 visitor->trace(m_temporaryStorage);
104 visitor->trace(m_persistentStorage); 105 visitor->trace(m_persistentStorage);
105 } 106 }
106 107
107 } // namespace blink 108 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/quota/DeprecatedStorageQuota.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698