summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/extension.h3
-rw-r--r--src/common/logger.h4
-rw-r--r--src/filesystem/js/common.js14
-rw-r--r--src/filesystem/js/file_handle.js8
-rw-r--r--src/filesystem/js/file_stream.js2
-rw-r--r--src/mediacontroller/mediacontroller_instance.cc8
-rwxr-xr-xsrc/metadata/metadata_api.js31
-rw-r--r--src/utils/utils_api.js14
8 files changed, 37 insertions, 47 deletions
diff --git a/src/common/extension.h b/src/common/extension.h
index f35c8226..404e3f7b 100644
--- a/src/common/extension.h
+++ b/src/common/extension.h
@@ -93,7 +93,8 @@ class Instance {
Instance();
virtual ~Instance();
- static void DoAndPostMessage(Instance* that, const std::function<void()>& work, const picojson::value& json);
+ static void DoAndPostMessage(Instance* that, const std::function<void()>& work,
+ const picojson::value& json);
static void PostMessage(Instance* that, const char* msg);
static void PostMessage(Instance* that, const picojson::value& json);
void PostMessage(const char* msg);
diff --git a/src/common/logger.h b/src/common/logger.h
index f2a1ef65..e4a6f3cd 100644
--- a/src/common/logger.h
+++ b/src/common/logger.h
@@ -112,8 +112,8 @@ int _printf_format_checker(const char* fmt, ...) {
#define LOGGER_IF(priority, condition) \
!(condition) ? (void)0 : LogMessageVoidify() & (LOGGER(priority))
-#define DEPRECATION_WARN(log, version) \
- /* For public code, warning should be always shown */ \
+#define DEPRECATION_WARN(log, version) \
+ /* For public code, warning should be always shown */ \
LoggerW("DEPRECATION WARNING: %s", log);
// This class more or less represents a particular log message.
diff --git a/src/filesystem/js/common.js b/src/filesystem/js/common.js
index 602abe9d..f1aa9b46 100644
--- a/src/filesystem/js/common.js
+++ b/src/filesystem/js/common.js
@@ -23,20 +23,6 @@ var types_ = validator_.Types;
var native_ = new xwalk.utils.NativeManager(extension);
/*
- * Create new array-like object of numbers: UTF-16 char codes from string.
- * As type pass Array, Uint8Array, etc.
- * Useful for passing data through crosswalk.
- */
-function StringToArray(str, type) {
- var len = str.length;
- var output = new type(len);
- for (var i = 0; i < len; i++) {
- output[i] = str.charCodeAt(i);
- }
- return output;
-}
-
-/*
* Pass array-like object of numbers (Array, Uint8Array, etc.), returns string.
* Each char has codepoint equal to value from array cropped with & 0xFF
* Useful for passing data through crosswalk.
diff --git a/src/filesystem/js/file_handle.js b/src/filesystem/js/file_handle.js
index 33563503..c8d4e42a 100644
--- a/src/filesystem/js/file_handle.js
+++ b/src/filesystem/js/file_handle.js
@@ -295,7 +295,7 @@ FileHandle.prototype.readBlob = function() {
throw native_.getErrorObject(result);
}
var encodedData = native_.getResultObject(result);
- var data = StringToArray(encodedData, Uint8Array);
+ var data = privUtils_.StringToArray(encodedData, Uint8Array);
return new Blob([data]);
};
@@ -330,7 +330,7 @@ FileHandle.prototype.readBlobNonBlocking = function() {
native_.callIfPossible(args.errorCallback, native_.getErrorObject(result));
} else {
var encodedData = native_.getResultObject(result);
- var data = StringToArray(encodedData, Uint8Array);
+ var data = privUtils_.StringToArray(encodedData, Uint8Array);
native_.callIfPossible(args.successCallback, new Blob([data]));
}
};
@@ -464,7 +464,7 @@ FileHandle.prototype.readData = function() {
throw native_.getErrorObject(result);
}
var encodedData = native_.getResultObject(result);
- var data = StringToArray(encodedData, Uint8Array);
+ var data = privUtils_.StringToArray(encodedData, Uint8Array);
return new Uint8Array(data);
};
@@ -511,7 +511,7 @@ FileHandle.prototype.readDataNonBlocking = function() {
native_.callIfPossible(args.errorCallback, native_.getErrorObject(result));
} else {
var data_out = new Uint8Array(
- StringToArray(native_.getResultObject(result), Uint8Array)
+ privUtils_.StringToArray(native_.getResultObject(result), Uint8Array)
);
native_.callIfPossible(args.successCallback, data_out);
}
diff --git a/src/filesystem/js/file_stream.js b/src/filesystem/js/file_stream.js
index 5364490b..cd89d988 100644
--- a/src/filesystem/js/file_stream.js
+++ b/src/filesystem/js/file_stream.js
@@ -185,7 +185,7 @@ function readBytes() {
throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Could not read');
}
- var decoded = StringToArray(native_.getResultObject(result), Array);
+ var decoded = privUtils_.StringToArray(native_.getResultObject(result), Array);
if (decoded.length) {
can_change_size = true;
diff --git a/src/mediacontroller/mediacontroller_instance.cc b/src/mediacontroller/mediacontroller_instance.cc
index 2c8c0952..f3cf189c 100644
--- a/src/mediacontroller/mediacontroller_instance.cc
+++ b/src/mediacontroller/mediacontroller_instance.cc
@@ -716,7 +716,8 @@ void MediaControllerInstance::MediaControllerServerDeletePlaylist(const picojson
LogAndReportError(result, &response_obj, ("Failed: server_->DeletePlaylist"));
}
- if (MEDIA_CONTROLLER_ERROR_NONE != mc_playlist_destroy(server_playlist_map_[serverName][name])) {
+ if (MEDIA_CONTROLLER_ERROR_NONE !=
+ mc_playlist_destroy(server_playlist_map_[serverName][name])) {
LoggerE("Unable to destroy playlist %s", name.c_str());
}
@@ -2140,9 +2141,8 @@ void MediaControllerInstance::MediaControllerPlaylistsGetPlaylist(const picojson
mc_playlist_h handle = nullptr;
if (server_playlist_map_.find(app_id) != server_playlist_map_.end() &&
- server_playlist_map_[app_id].find(playlist_name) !=
- server_playlist_map_[app_id].end()) {
- LoggerD("Using saved handle");
+ server_playlist_map_[app_id].find(playlist_name) != server_playlist_map_[app_id].end()) {
+ LoggerD("Using saved handle");
handle = server_playlist_map_[app_id][playlist_name];
}
diff --git a/src/metadata/metadata_api.js b/src/metadata/metadata_api.js
index 62790de9..f054addc 100755
--- a/src/metadata/metadata_api.js
+++ b/src/metadata/metadata_api.js
@@ -19,7 +19,7 @@ var validator_ = privUtils_.validator;
var types_ = validator_.Types;
var native_ = new xwalk.utils.NativeManager(extension);
-var DEFAULT_BLOB_MIME_TYPE = "image/jpeg"
+var DEFAULT_BLOB_MIME_TYPE = 'image/jpeg';
var MetadataType = {
ALBUM: 'ALBUM',
@@ -127,23 +127,6 @@ MetadataFileHandle.prototype.release = function() {
return native_.getResultObject(result);
};
-// below section copied from filesystem
-// TODO move this to utils?
-/*
- * Create new array-like object of numbers: UTF-16 char codes from string.
- * As type pass Array, Uint8Array, etc.
- * Useful for passing data through crosswalk.
- */
-function StringToArray(str, type) {
- var len = str.length;
- var output = new type(len);
- for (var i = 0; i < len; i++) {
- output[i] = str.charCodeAt(i);
- }
- return output;
-}
-////////////////////////////////////////////////////
-
MetadataFileHandle.prototype.getArtwork = function() {
var data = {
uri: this.uri,
@@ -155,7 +138,7 @@ MetadataFileHandle.prototype.getArtwork = function() {
throw native_.getErrorObject(result);
}
var resultData = native_.getResultObject(result);
- var encodedData = StringToArray(resultData.encodedData, Uint8Array);
+ var encodedData = privUtils_.StringToArray(resultData.encodedData, Uint8Array);
return new Blob([encodedData], { type: resultData.mimeType });
};
@@ -170,7 +153,10 @@ MetadataFileHandle.prototype.getThumbnailFrame = function() {
if (native_.isFailure(result)) {
throw native_.getErrorObject(result);
}
- var encodedData = StringToArray(native_.getResultObject(result), Uint8Array);
+ var encodedData = privUtils_.StringToArray(
+ native_.getResultObject(result),
+ Uint8Array
+ );
return new Blob([encodedData], { type: DEFAULT_BLOB_MIME_TYPE });
};
@@ -192,7 +178,10 @@ MetadataFileHandle.prototype.getFrameAtTime = function() {
if (native_.isFailure(result)) {
throw native_.getErrorObject(result);
}
- var encodedData = StringToArray(native_.getResultObject(result), Uint8Array);
+ var encodedData = privUtils_.StringToArray(
+ native_.getResultObject(result),
+ Uint8Array
+ );
return new Blob([encodedData], { type: DEFAULT_BLOB_MIME_TYPE });
};
diff --git a/src/utils/utils_api.js b/src/utils/utils_api.js
index 33ee00b1..76a2d670 100644
--- a/src/utils/utils_api.js
+++ b/src/utils/utils_api.js
@@ -385,6 +385,20 @@ Utils.prototype.printDeprecationWarningFor = function(name, replacement) {
}
};
+/*
+ * Create new array-like object of numbers: UTF-16 char codes from string.
+ * As type pass Array, Uint8Array, etc.
+ * Useful for passing data through crosswalk.
+ */
+Utils.prototype.StringToArray = function(str, type) {
+ var len = str.length;
+ var output = new type(len);
+ for (var i = 0; i < len; i++) {
+ output[i] = str.charCodeAt(i);
+ }
+ return output;
+};
+
/////////////////////////////////////////////////////////////////////////////
/** @constructor */
var Type = function() {};