| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "sky/viewer/platform/platform_impl.h" | 5 #include "sky/viewer/platform/platform_impl.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "mojo/public/cpp/application/application_impl.h" | 14 #include "mojo/public/cpp/application/application_impl.h" |
| 15 #include "net/base/data_url.h" | 15 #include "net/base/data_url.h" |
| 16 #include "net/base/mime_util.h" | 16 #include "net/base/mime_util.h" |
| 17 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
| 18 #include "sky/engine/public/platform/WebConvertableToTraceFormat.h" | 18 #include "sky/engine/public/platform/WebConvertableToTraceFormat.h" |
| 19 #include "sky/viewer/platform/weburlloader_impl.h" | 19 #include "sky/viewer/platform/weburlloader_impl.h" |
| 20 #include "base/files/file_util.h" |
| 21 #include "base/files/file_path.h" |
| 22 #include "base/path_service.h" |
| 20 | 23 |
| 21 namespace sky { | 24 namespace sky { |
| 22 namespace { | 25 namespace { |
| 23 | 26 |
| 24 class ConvertableToTraceFormatWrapper | 27 class ConvertableToTraceFormatWrapper |
| 25 : public base::debug::ConvertableToTraceFormat { | 28 : public base::debug::ConvertableToTraceFormat { |
| 26 public: | 29 public: |
| 27 explicit ConvertableToTraceFormatWrapper( | 30 explicit ConvertableToTraceFormatWrapper( |
| 28 const blink::WebConvertableToTraceFormat& convertable) | 31 const blink::WebConvertableToTraceFormat& convertable) |
| 29 : convertable_(convertable) {} | 32 : convertable_(convertable) {} |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 void PlatformImpl::updateTraceEventDuration( | 231 void PlatformImpl::updateTraceEventDuration( |
| 229 const unsigned char* category_group_enabled, | 232 const unsigned char* category_group_enabled, |
| 230 const char* name, | 233 const char* name, |
| 231 TraceEventHandle handle) { | 234 TraceEventHandle handle) { |
| 232 base::debug::TraceEventHandle traceEventHandle; | 235 base::debug::TraceEventHandle traceEventHandle; |
| 233 memcpy(&traceEventHandle, &handle, sizeof(handle)); | 236 memcpy(&traceEventHandle, &handle, sizeof(handle)); |
| 234 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION( | 237 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION( |
| 235 category_group_enabled, name, traceEventHandle); | 238 category_group_enabled, name, traceEventHandle); |
| 236 } | 239 } |
| 237 | 240 |
| 241 blink::WebData PlatformImpl::loadResource(const char* name) |
| 242 { |
| 243 base::FilePath root_dir; |
| 244 PathService::Get(base::DIR_SOURCE_ROOT, &root_dir); |
| 245 base::FilePath engine_dir = root_dir.AppendASCII("sky").AppendASCII("engine"); |
| 246 base::FilePath v8_dir = engine_dir.AppendASCII("bindings").AppendASCII("core")
.AppendASCII("v8"); |
| 247 base::FilePath inspector_dir = engine_dir.AppendASCII("core").AppendASCII("ins
pector"); |
| 248 |
| 249 base::FilePath path; |
| 250 if (std::string("InjectedScriptSource.js") == name) |
| 251 path = inspector_dir.AppendASCII(name); |
| 252 else if (std::string("DebuggerScript.js") == name) |
| 253 path = v8_dir.AppendASCII(name); |
| 254 else |
| 255 CHECK(false); |
| 256 |
| 257 printf("%s\n", path.value().c_str()); |
| 258 printf("%s\n", name); |
| 259 |
| 260 std::string buffer; |
| 261 base::ReadFileToString(path, &buffer); |
| 262 CHECK(!buffer.empty()); |
| 263 return blink::WebData(buffer.data(), buffer.size()); |
| 264 } |
| 265 |
| 238 } // namespace sky | 266 } // namespace sky |
| OLD | NEW |