OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/support/webkit_support.h" | 5 #include "webkit/support/webkit_support.h" |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/base64.h" | 8 #include "base/base64.h" |
9 #include "base/bind.h" | |
csilv
2011/11/21 21:26:31
add #include base/bind_helpers.h
dcheng
2011/11/21 22:04:16
Done.
| |
9 #include "base/command_line.h" | 10 #include "base/command_line.h" |
10 #include "base/debug/debugger.h" | 11 #include "base/debug/debugger.h" |
11 #include "base/file_path.h" | 12 #include "base/file_path.h" |
12 #include "base/file_util.h" | 13 #include "base/file_util.h" |
13 #include "base/i18n/icu_util.h" | 14 #include "base/i18n/icu_util.h" |
14 #include "base/logging.h" | 15 #include "base/logging.h" |
15 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
16 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
17 #include "base/message_loop.h" | 18 #include "base/message_loop.h" |
18 #include "base/path_service.h" | 19 #include "base/path_service.h" |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
200 message_loop_->Run(); | 201 message_loop_->Run(); |
201 message_loop_->SetNestableTasksAllowed(old_state); | 202 message_loop_->SetNestableTasksAllowed(old_state); |
202 } | 203 } |
203 virtual void quitNow() { | 204 virtual void quitNow() { |
204 message_loop_->QuitNow(); | 205 message_loop_->QuitNow(); |
205 } | 206 } |
206 private: | 207 private: |
207 MessageLoop* message_loop_; | 208 MessageLoop* message_loop_; |
208 }; | 209 }; |
209 | 210 |
210 // An wrapper object for giving TaskAdaptor ref-countability, | |
211 // which NewRunnableMethod() requires. | |
212 class TaskAdaptorHolder : public CancelableTask { | |
213 public: | |
214 explicit TaskAdaptorHolder(webkit_support::TaskAdaptor* adaptor) | |
215 : adaptor_(adaptor) { | |
216 } | |
217 | |
218 virtual void Run() { | |
219 adaptor_->Run(); | |
220 } | |
221 | |
222 virtual void Cancel() { | |
223 adaptor_.reset(); | |
224 } | |
225 | |
226 private: | |
227 scoped_ptr<webkit_support::TaskAdaptor> adaptor_; | |
228 }; | |
229 | |
230 webkit_support::GraphicsContext3DImplementation | 211 webkit_support::GraphicsContext3DImplementation |
231 g_graphics_context_3d_implementation = | 212 g_graphics_context_3d_implementation = |
232 webkit_support::IN_PROCESS_COMMAND_BUFFER; | 213 webkit_support::IN_PROCESS_COMMAND_BUFFER; |
233 | 214 |
234 } // namespace | 215 } // namespace |
235 | 216 |
236 namespace webkit_support { | 217 namespace webkit_support { |
237 | 218 |
238 static TestEnvironment* test_environment; | 219 static TestEnvironment* test_environment; |
239 | 220 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
421 current->RunAllPending(); | 402 current->RunAllPending(); |
422 current->SetNestableTasksAllowed(old_state); | 403 current->SetNestableTasksAllowed(old_state); |
423 } | 404 } |
424 | 405 |
425 WebDevToolsAgentClient::WebKitClientMessageLoop* CreateDevToolsMessageLoop() { | 406 WebDevToolsAgentClient::WebKitClientMessageLoop* CreateDevToolsMessageLoop() { |
426 return new WebKitClientMessageLoopImpl(); | 407 return new WebKitClientMessageLoopImpl(); |
427 } | 408 } |
428 | 409 |
429 void PostDelayedTask(void (*func)(void*), void* context, int64 delay_ms) { | 410 void PostDelayedTask(void (*func)(void*), void* context, int64 delay_ms) { |
430 MessageLoop::current()->PostDelayedTask( | 411 MessageLoop::current()->PostDelayedTask( |
431 FROM_HERE, NewRunnableFunction(func, context), delay_ms); | 412 FROM_HERE, base::Bind(func, context), delay_ms); |
432 } | 413 } |
433 | 414 |
434 void PostDelayedTask(TaskAdaptor* task, int64 delay_ms) { | 415 void PostDelayedTask(TaskAdaptor* task, int64 delay_ms) { |
435 MessageLoop::current()->PostDelayedTask( | 416 MessageLoop::current()->PostDelayedTask( |
436 FROM_HERE, new TaskAdaptorHolder(task), delay_ms); | 417 FROM_HERE, base::Bind(&TaskAdaptor::Run, base::Owned(task)), delay_ms); |
437 } | 418 } |
438 | 419 |
439 // Wrappers for FilePath and file_util | 420 // Wrappers for FilePath and file_util |
440 | 421 |
441 WebString GetAbsoluteWebStringFromUTF8Path(const std::string& utf8_path) { | 422 WebString GetAbsoluteWebStringFromUTF8Path(const std::string& utf8_path) { |
442 #if defined(OS_WIN) | 423 #if defined(OS_WIN) |
443 FilePath path(UTF8ToWide(utf8_path)); | 424 FilePath path(UTF8ToWide(utf8_path)); |
444 file_util::AbsolutePath(&path); | 425 file_util::AbsolutePath(&path); |
445 return WebString(path.value()); | 426 return WebString(path.value()); |
446 #else | 427 #else |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
640 double GetForegroundTabTimerInterval() { | 621 double GetForegroundTabTimerInterval() { |
641 return webkit_glue::kForegroundTabTimerInterval; | 622 return webkit_glue::kForegroundTabTimerInterval; |
642 } | 623 } |
643 | 624 |
644 // Logging | 625 // Logging |
645 void EnableWebCoreLogChannels(const std::string& channels) { | 626 void EnableWebCoreLogChannels(const std::string& channels) { |
646 webkit_glue::EnableWebCoreLogChannels(channels); | 627 webkit_glue::EnableWebCoreLogChannels(channels); |
647 } | 628 } |
648 | 629 |
649 } // namespace webkit_support | 630 } // namespace webkit_support |
OLD | NEW |