OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/renderer_host/resource_message_filter.h" | 5 #include "chrome/browser/renderer_host/resource_message_filter.h" |
6 | 6 |
7 #include "app/clipboard/clipboard.h" | 7 #include "app/clipboard/clipboard.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #if defined(OS_POSIX) | 10 #if defined(OS_POSIX) |
11 #include "base/file_descriptor_posix.h" | 11 #include "base/file_descriptor_posix.h" |
12 #endif | 12 #endif |
13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
14 #include "base/histogram.h" | 14 #include "base/histogram.h" |
15 #include "base/process_util.h" | 15 #include "base/process_util.h" |
16 #include "base/thread.h" | 16 #include "base/thread.h" |
17 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
| 18 #include "base/worker_pool.h" |
18 #include "chrome/browser/appcache/appcache_dispatcher_host.h" | 19 #include "chrome/browser/appcache/appcache_dispatcher_host.h" |
19 #include "chrome/browser/browser_about_handler.h" | 20 #include "chrome/browser/browser_about_handler.h" |
20 #include "chrome/browser/child_process_security_policy.h" | 21 #include "chrome/browser/child_process_security_policy.h" |
21 #include "chrome/browser/chrome_plugin_browsing_context.h" | 22 #include "chrome/browser/chrome_plugin_browsing_context.h" |
22 #include "chrome/browser/chrome_thread.h" | 23 #include "chrome/browser/chrome_thread.h" |
23 #include "chrome/browser/download/download_file.h" | 24 #include "chrome/browser/download/download_file.h" |
24 #include "chrome/browser/extensions/extension_message_service.h" | 25 #include "chrome/browser/extensions/extension_message_service.h" |
25 #include "chrome/browser/geolocation/geolocation_permission_context.h" | 26 #include "chrome/browser/geolocation/geolocation_permission_context.h" |
26 #include "chrome/browser/geolocation/geolocation_dispatcher_host.h" | 27 #include "chrome/browser/geolocation/geolocation_dispatcher_host.h" |
27 #include "chrome/browser/gpu_process_host.h" | 28 #include "chrome/browser/gpu_process_host.h" |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 IPC_MESSAGE_HANDLER(ViewHostMsg_CloseCurrentConnections, | 581 IPC_MESSAGE_HANDLER(ViewHostMsg_CloseCurrentConnections, |
581 OnCloseCurrentConnections) | 582 OnCloseCurrentConnections) |
582 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCacheMode, OnSetCacheMode) | 583 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCacheMode, OnSetCacheMode) |
583 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_ClearCache, OnClearCache) | 584 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_ClearCache, OnClearCache) |
584 IPC_MESSAGE_HANDLER(ViewHostMsg_DidGenerateCacheableMetadata, | 585 IPC_MESSAGE_HANDLER(ViewHostMsg_DidGenerateCacheableMetadata, |
585 OnCacheableMetadataAvailable) | 586 OnCacheableMetadataAvailable) |
586 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetFileSize, OnGetFileSize) | 587 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetFileSize, OnGetFileSize) |
587 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetFileModificationTime, | 588 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetFileModificationTime, |
588 OnGetFileModificationTime) | 589 OnGetFileModificationTime) |
589 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_OpenFile, OnOpenFile) | 590 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_OpenFile, OnOpenFile) |
590 IPC_MESSAGE_HANDLER(ViewHostMsg_Keygen, OnKeygen) | 591 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_Keygen, OnKeygen) |
591 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetExtensionMessageBundle, | 592 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetExtensionMessageBundle, |
592 OnGetExtensionMessageBundle) | 593 OnGetExtensionMessageBundle) |
593 #if defined(USE_TCMALLOC) | 594 #if defined(USE_TCMALLOC) |
594 IPC_MESSAGE_HANDLER(ViewHostMsg_RendererTcmalloc, OnRendererTcmalloc) | 595 IPC_MESSAGE_HANDLER(ViewHostMsg_RendererTcmalloc, OnRendererTcmalloc) |
595 #endif | 596 #endif |
596 IPC_MESSAGE_HANDLER(ViewHostMsg_EstablishGpuChannel, | 597 IPC_MESSAGE_HANDLER(ViewHostMsg_EstablishGpuChannel, |
597 OnEstablishGpuChannel) | 598 OnEstablishGpuChannel) |
598 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_SynchronizeGpu, | 599 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_SynchronizeGpu, |
599 OnSynchronizeGpu) | 600 OnSynchronizeGpu) |
600 IPC_MESSAGE_UNHANDLED( | 601 IPC_MESSAGE_UNHANDLED( |
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1570 ); | 1571 ); |
1571 | 1572 |
1572 ChromeThread::PostTask( | 1573 ChromeThread::PostTask( |
1573 ChromeThread::IO, FROM_HERE, | 1574 ChromeThread::IO, FROM_HERE, |
1574 NewRunnableMethod(this, &ResourceMessageFilter::Send, reply_msg)); | 1575 NewRunnableMethod(this, &ResourceMessageFilter::Send, reply_msg)); |
1575 } | 1576 } |
1576 | 1577 |
1577 void ResourceMessageFilter::OnKeygen(uint32 key_size_index, | 1578 void ResourceMessageFilter::OnKeygen(uint32 key_size_index, |
1578 const std::string& challenge_string, | 1579 const std::string& challenge_string, |
1579 const GURL& url, | 1580 const GURL& url, |
1580 std::string* signed_public_key) { | 1581 IPC::Message* reply_msg) { |
1581 // Map displayed strings indicating level of keysecurity in the <keygen> | 1582 // Map displayed strings indicating level of keysecurity in the <keygen> |
1582 // menu to the key size in bits. (See SSLKeyGeneratorChromium.cpp in WebCore.) | 1583 // menu to the key size in bits. (See SSLKeyGeneratorChromium.cpp in WebCore.) |
1583 int key_size_in_bits; | 1584 int key_size_in_bits; |
1584 switch (key_size_index) { | 1585 switch (key_size_index) { |
1585 case 0: | 1586 case 0: |
1586 key_size_in_bits = 2048; | 1587 key_size_in_bits = 2048; |
1587 break; | 1588 break; |
1588 case 1: | 1589 case 1: |
1589 key_size_in_bits = 1024; | 1590 key_size_in_bits = 1024; |
1590 break; | 1591 break; |
1591 default: | 1592 default: |
1592 DCHECK(false) << "Illegal key_size_index " << key_size_index; | 1593 DCHECK(false) << "Illegal key_size_index " << key_size_index; |
1593 *signed_public_key = std::string(); | 1594 ViewHostMsg_Keygen::WriteReplyParams(reply_msg, std::string()); |
| 1595 Send(reply_msg); |
1594 return; | 1596 return; |
1595 } | 1597 } |
| 1598 |
| 1599 LOG(INFO) << "Dispatching keygen task to worker pool."; |
| 1600 // Dispatch to worker pool, so we do not block the IO thread. |
| 1601 if (!WorkerPool::PostTask( |
| 1602 FROM_HERE, |
| 1603 NewRunnableMethod( |
| 1604 this, &ResourceMessageFilter::OnKeygenOnWorkerThread, |
| 1605 key_size_in_bits, challenge_string, reply_msg), |
| 1606 true)) { |
| 1607 NOTREACHED() << "Failed to dispatch keygen task to worker pool"; |
| 1608 ViewHostMsg_Keygen::WriteReplyParams(reply_msg, std::string()); |
| 1609 Send(reply_msg); |
| 1610 return; |
| 1611 } |
| 1612 } |
| 1613 |
| 1614 void ResourceMessageFilter::OnKeygenOnWorkerThread( |
| 1615 int key_size_in_bits, |
| 1616 const std::string& challenge_string, |
| 1617 IPC::Message* reply_msg) { |
| 1618 DCHECK(reply_msg); |
| 1619 // Verify we are on a worker thread. |
| 1620 DCHECK(!MessageLoop::current()); |
| 1621 |
| 1622 // Generate a signed public key and challenge, then send it back. |
1596 net::KeygenHandler keygen_handler(key_size_in_bits, challenge_string); | 1623 net::KeygenHandler keygen_handler(key_size_in_bits, challenge_string); |
1597 *signed_public_key = keygen_handler.GenKeyAndSignChallenge(); | 1624 |
| 1625 ViewHostMsg_Keygen::WriteReplyParams( |
| 1626 reply_msg, |
| 1627 keygen_handler.GenKeyAndSignChallenge()); |
| 1628 |
| 1629 ChromeThread::PostTask( |
| 1630 ChromeThread::IO, FROM_HERE, |
| 1631 NewRunnableMethod(this, &ResourceMessageFilter::Send, reply_msg)); |
1598 } | 1632 } |
1599 | 1633 |
1600 #if defined(USE_TCMALLOC) | 1634 #if defined(USE_TCMALLOC) |
1601 void ResourceMessageFilter::OnRendererTcmalloc(base::ProcessId pid, | 1635 void ResourceMessageFilter::OnRendererTcmalloc(base::ProcessId pid, |
1602 const std::string& output) { | 1636 const std::string& output) { |
1603 ChromeThread::PostTask( | 1637 ChromeThread::PostTask( |
1604 ChromeThread::UI, FROM_HERE, | 1638 ChromeThread::UI, FROM_HERE, |
1605 NewRunnableFunction(AboutTcmallocRendererCallback, pid, output)); | 1639 NewRunnableFunction(AboutTcmallocRendererCallback, pid, output)); |
1606 } | 1640 } |
1607 #endif | 1641 #endif |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1659 dictionary_map.insert( | 1693 dictionary_map.insert( |
1660 std::make_pair(ExtensionMessageBundle::kExtensionIdKey, extension_id)); | 1694 std::make_pair(ExtensionMessageBundle::kExtensionIdKey, extension_id)); |
1661 | 1695 |
1662 ViewHostMsg_GetExtensionMessageBundle::WriteReplyParams( | 1696 ViewHostMsg_GetExtensionMessageBundle::WriteReplyParams( |
1663 reply_msg, dictionary_map); | 1697 reply_msg, dictionary_map); |
1664 | 1698 |
1665 ChromeThread::PostTask( | 1699 ChromeThread::PostTask( |
1666 ChromeThread::IO, FROM_HERE, | 1700 ChromeThread::IO, FROM_HERE, |
1667 NewRunnableMethod(this, &ResourceMessageFilter::Send, reply_msg)); | 1701 NewRunnableMethod(this, &ResourceMessageFilter::Send, reply_msg)); |
1668 } | 1702 } |
OLD | NEW |