2014-01-04 18:59:55 +00:00
/ *
Copyright 2014 Google Inc .
Licensed under the Apache License , Version 2.0 ( the "License" ) ;
you may not use this file except in compliance with the License .
You may obtain a copy of the License at
2014-01-07 04:52:30 +00:00
http : //www.apache.org/licenses/LICENSE-2.0
2014-01-04 18:59:55 +00:00
Unless required by applicable law or agreed to in writing , software
distributed under the License is distributed on an "AS IS" BASIS ,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
See the License for the specific language governing permissions and
limitations under the License .
* /
// These two lines are required setup to make goog.require() work throughout the codebase.
var CLOSURE _BASE _PATH = 'closure/goog/' ;
importScripts ( 'closure/goog/bootstrap/webworkers.js' , 'closure/goog/base.js' , 'deps.js' ) ;
2014-01-08 05:28:01 +00:00
goog . require ( 'cam.blob' ) ;
goog . require ( 'cam.WorkerMessageRouter' ) ;
2014-01-04 18:59:55 +00:00
// This is a simple webworker that expects to receive a single message containing a file, and sends back that file's sha1 hash.
// We do this in a worker because we observed that doing it on the main thread decreased the framerate significantly, even when chunking, and even when the chunk sizes were as small as 32k.
2014-01-08 05:28:01 +00:00
var router = new cam . WorkerMessageRouter ( goog . global ) ;
2014-01-04 18:59:55 +00:00
router . registerHandler ( 'ref' , function ( msg , sendReply ) {
2014-01-08 05:28:01 +00:00
sendReply ( cam . blob . refFromDOMBlob ( msg ) ) ;
2014-01-04 18:59:55 +00:00
} ) ;