2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 #include <JavaScriptCore/JavaScript.h>
19 #include <dpl/shared_ptr.h>
20 #include <CommonsJavaScript/PrivateObject.h>
21 #include <CommonsJavaScript/JSCallbackManager.h>
22 #include <CommonsJavaScript/Converter.h>
23 #include <Commons/IEvent.h>
24 #include <CommonsJavaScript/JSDOMExceptionFactory.h>
25 #include "EventStorageStateChanged.h"
26 #include "StorageStaticController.h"
27 #include "JSStorage.h"
28 #include "Converter.h"
31 using namespace WrtDeviceApis;
32 using namespace WrtDeviceApis::Commons;
33 using namespace WrtDeviceApis::CommonsJavaScript;
36 namespace Filesystem {
37 StorageStaticController& StorageStaticController::getInstance()
39 static StorageStaticController controller;
43 StorageStaticController::StorageStaticController() :
44 EventListener<EventStorageStateChanged>(ThreadEnum::NULL_THREAD)
48 void StorageStaticController::onAnswerReceived(
49 const EventStorageStateChangedPtr& event)
51 JSCallbackManagerPtr callbackManager =
52 DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
54 JSContextRef context = callbackManager->getContext();
55 Converter converter(context);
57 JSValueRef result = converter.toJSValueRef(event->getResult(), context);
58 callbackManager->callOnSuccess(result);
59 } catch(Commons::ConversionException) {
60 LoggerE("Conversion exception while processing EventStorageStateChanged");