| 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/files/file_path.h" | |
| 11 #include "base/files/file_util.h" | |
| 12 #include "base/path_service.h" | |
| 13 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
| 14 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 15 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
| 16 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 17 #include "mojo/public/cpp/application/application_impl.h" | 14 #include "mojo/public/cpp/application/application_impl.h" |
| 18 #include "net/base/data_url.h" | 15 #include "net/base/data_url.h" |
| 19 #include "net/base/mime_util.h" | 16 #include "net/base/mime_util.h" |
| 20 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
| 21 #include "sky/engine/public/platform/WebConvertableToTraceFormat.h" | 18 #include "sky/engine/public/platform/WebConvertableToTraceFormat.h" |
| 22 #include "sky/viewer/platform/weburlloader_impl.h" | 19 #include "sky/viewer/platform/weburlloader_impl.h" |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 void PlatformImpl::updateTraceEventDuration( | 220 void PlatformImpl::updateTraceEventDuration( |
| 224 const unsigned char* category_group_enabled, | 221 const unsigned char* category_group_enabled, |
| 225 const char* name, | 222 const char* name, |
| 226 TraceEventHandle handle) { | 223 TraceEventHandle handle) { |
| 227 base::debug::TraceEventHandle traceEventHandle; | 224 base::debug::TraceEventHandle traceEventHandle; |
| 228 memcpy(&traceEventHandle, &handle, sizeof(handle)); | 225 memcpy(&traceEventHandle, &handle, sizeof(handle)); |
| 229 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION( | 226 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION( |
| 230 category_group_enabled, name, traceEventHandle); | 227 category_group_enabled, name, traceEventHandle); |
| 231 } | 228 } |
| 232 | 229 |
| 233 // FIXME(sky): This is a horrible hack and makes sky only work when run | |
| 234 // inside its source tree! crbug.com/434513 | |
| 235 blink::WebData PlatformImpl::loadResource(const char* name) | |
| 236 { | |
| 237 base::FilePath root_dir; | |
| 238 PathService::Get(base::DIR_SOURCE_ROOT, &root_dir); | |
| 239 base::FilePath engine_dir = root_dir.AppendASCII("sky").AppendASCII("engine"); | |
| 240 base::FilePath v8_dir = engine_dir.AppendASCII("bindings").AppendASCII("core")
.AppendASCII("v8"); | |
| 241 base::FilePath inspector_dir = engine_dir.AppendASCII("core").AppendASCII("ins
pector"); | |
| 242 | |
| 243 base::FilePath path; | |
| 244 if (std::string("InjectedScriptSource.js") == name) | |
| 245 path = inspector_dir.AppendASCII(name); | |
| 246 else if (std::string("DebuggerScript.js") == name) | |
| 247 path = v8_dir.AppendASCII(name); | |
| 248 else | |
| 249 CHECK(false); | |
| 250 | |
| 251 std::string buffer; | |
| 252 base::ReadFileToString(path, &buffer); | |
| 253 CHECK(!buffer.empty()); | |
| 254 return blink::WebData(buffer.data(), buffer.size()); | |
| 255 } | |
| 256 | |
| 257 } // namespace sky | 230 } // namespace sky |
| OLD | NEW |