1 // Copyright 2014 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef COMPONENTS_NACL_RENDERER_PROGRESS_EVENT_H_ 6 #define COMPONENTS_NACL_RENDERER_PROGRESS_EVENT_H_ 7 8 #include <stdint.h> 9 10 #include <string> 11 12 #include "components/nacl/renderer/ppb_nacl_private.h" 13 #include "ppapi/c/pp_instance.h" 14 15 namespace nacl { 16 17 // See http://www.w3.org/TR/progress-events/ for more details on progress 18 // events. 19 struct ProgressEvent { ProgressEventProgressEvent20 explicit ProgressEvent(PP_NaClEventType event_type_param) 21 : event_type(event_type_param), 22 length_is_computable(false), 23 loaded_bytes(0), 24 total_bytes(0) { 25 } 26 ProgressEventProgressEvent27 ProgressEvent(PP_NaClEventType event_type_param, 28 const std::string& resource_url_param, 29 bool length_is_computable_param, 30 uint64_t loaded_bytes_param, 31 uint64_t total_bytes_param) 32 : event_type(event_type_param), 33 resource_url(resource_url_param), 34 length_is_computable(length_is_computable_param), 35 loaded_bytes(loaded_bytes_param), 36 total_bytes(total_bytes_param) { 37 } 38 39 PP_NaClEventType event_type; 40 std::string resource_url; 41 bool length_is_computable; 42 uint64_t loaded_bytes; 43 uint64_t total_bytes; 44 }; 45 46 // Dispatches a progress event to the DOM frame corresponding to the specified 47 // plugin instance. 48 // This posts a task to the main thread to perform the actual dispatch, since 49 // it's usually intended for progress events to be dispatched after all other 50 // state changes are handled. 51 void DispatchProgressEvent(PP_Instance instance, const ProgressEvent& event); 52 53 } // namespace nacl 54 55 #endif // COMPONENTS_NACL_RENDERER_PROGRESS_EVENT_H_ 56