зеркало из https://github.com/mozilla/gecko-dev.git
Mozilla-specific changes to the Chromium code, imported verbatim from http://hg.mozilla.org/users/bturner_mozilla.com/libchromiumipc/
This commit is contained in:
Родитель
a90c9ba160
Коммит
b9b077cb23
|
@ -7,6 +7,10 @@
|
|||
#ifndef BASE_BASE_SWITCHES_H_
|
||||
#define BASE_BASE_SWITCHES_H_
|
||||
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD) && defined(COMPILER_MSVC)
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
namespace switches {
|
||||
|
||||
extern const wchar_t kDebugOnStart[];
|
||||
|
|
|
@ -23,6 +23,10 @@
|
|||
#include "base/message_pump_glib.h"
|
||||
#endif
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
#include "MessagePump.h"
|
||||
#endif
|
||||
|
||||
using base::Time;
|
||||
using base::TimeDelta;
|
||||
|
||||
|
@ -84,6 +88,16 @@ MessageLoop::MessageLoop(Type type)
|
|||
DCHECK(!current()) << "should only have one message loop per thread";
|
||||
lazy_tls_ptr.Pointer()->Set(this);
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
if (type_ == TYPE_UI) {
|
||||
pump_ = new mozilla::ipc::MessagePump();
|
||||
return;
|
||||
}
|
||||
if (type_ == TYPE_MOZILLA_CHILD) {
|
||||
pump_ = new mozilla::ipc::MessagePumpForChildProcess();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#if defined(OS_WIN)
|
||||
// TODO(rvargas): Get rid of the OS guards.
|
||||
if (type_ == TYPE_DEFAULT) {
|
||||
|
@ -187,7 +201,7 @@ void MessageLoop::RunInternal() {
|
|||
|
||||
StartHistogrammer();
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if defined(OS_WIN) && !defined(CHROMIUM_MOZILLA_BUILD)
|
||||
if (state_->dispatcher) {
|
||||
pump_win()->RunWithDispatcher(this, state_->dispatcher);
|
||||
return;
|
||||
|
|
|
@ -185,6 +185,9 @@ class MessageLoop : public base::MessagePump::Delegate {
|
|||
TYPE_DEFAULT,
|
||||
TYPE_UI,
|
||||
TYPE_IO
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
, TYPE_MOZILLA_CHILD
|
||||
#endif
|
||||
};
|
||||
|
||||
// Normally, it is not necessary to instantiate a MessageLoop. Instead, it
|
||||
|
|
|
@ -22,7 +22,11 @@ class MessagePumpDefault : public MessagePump {
|
|||
virtual void ScheduleWork();
|
||||
virtual void ScheduleDelayedWork(const Time& delayed_work_time);
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
protected:
|
||||
#else
|
||||
private:
|
||||
#endif
|
||||
// This flag is set to false when Run should return.
|
||||
bool keep_running_;
|
||||
|
||||
|
@ -32,6 +36,9 @@ class MessagePumpDefault : public MessagePump {
|
|||
// The time at which we should call DoDelayedWork.
|
||||
Time delayed_work_time_;
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
private:
|
||||
#endif
|
||||
DISALLOW_COPY_AND_ASSIGN(MessagePumpDefault);
|
||||
};
|
||||
|
||||
|
|
|
@ -88,6 +88,34 @@ bool Pickle::ReadBool(void** iter, bool* result) const {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Pickle::ReadInt16(void** iter, int16* result) const {
|
||||
DCHECK(iter);
|
||||
if (!*iter)
|
||||
*iter = const_cast<char*>(payload());
|
||||
|
||||
if (!IteratorHasRoomFor(*iter, sizeof(*result)))
|
||||
return false;
|
||||
|
||||
memcpy(result, *iter, sizeof(*result));
|
||||
|
||||
UpdateIter(iter, sizeof(*result));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Pickle::ReadUInt16(void** iter, uint16* result) const {
|
||||
DCHECK(iter);
|
||||
if (!*iter)
|
||||
*iter = const_cast<char*>(payload());
|
||||
|
||||
if (!IteratorHasRoomFor(*iter, sizeof(*result)))
|
||||
return false;
|
||||
|
||||
memcpy(result, *iter, sizeof(*result));
|
||||
|
||||
UpdateIter(iter, sizeof(*result));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Pickle::ReadInt(void** iter, int* result) const {
|
||||
DCHECK(iter);
|
||||
if (!*iter)
|
||||
|
@ -121,6 +149,22 @@ bool Pickle::ReadLong(void** iter, long* result) const {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Pickle::ReadULong(void** iter, unsigned long* result) const {
|
||||
DCHECK(iter);
|
||||
if (!*iter)
|
||||
*iter = const_cast<char*>(payload());
|
||||
|
||||
if (!IteratorHasRoomFor(*iter, sizeof(*result)))
|
||||
return false;
|
||||
|
||||
// TODO(jar) bug 1129285: Pickle should be cleaned up, and not dependent on
|
||||
// alignment.
|
||||
memcpy(result, *iter, sizeof(*result));
|
||||
|
||||
UpdateIter(iter, sizeof(*result));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Pickle::ReadLength(void** iter, int* result) const {
|
||||
if (!ReadInt(iter, result))
|
||||
return false;
|
||||
|
@ -188,6 +232,8 @@ bool Pickle::ReadIntPtr(void** iter, intptr_t* result) const {
|
|||
|
||||
bool Pickle::ReadString(void** iter, std::string* result) const {
|
||||
DCHECK(iter);
|
||||
if (!*iter)
|
||||
*iter = const_cast<char*>(payload());
|
||||
|
||||
int len;
|
||||
if (!ReadLength(iter, &len))
|
||||
|
@ -204,6 +250,8 @@ bool Pickle::ReadString(void** iter, std::string* result) const {
|
|||
|
||||
bool Pickle::ReadWString(void** iter, std::wstring* result) const {
|
||||
DCHECK(iter);
|
||||
if (!*iter)
|
||||
*iter = const_cast<char*>(payload());
|
||||
|
||||
int len;
|
||||
if (!ReadLength(iter, &len))
|
||||
|
@ -220,6 +268,8 @@ bool Pickle::ReadWString(void** iter, std::wstring* result) const {
|
|||
|
||||
bool Pickle::ReadString16(void** iter, string16* result) const {
|
||||
DCHECK(iter);
|
||||
if (!*iter)
|
||||
*iter = const_cast<char*>(payload());
|
||||
|
||||
int len;
|
||||
if (!ReadLength(iter, &len))
|
||||
|
@ -237,6 +287,8 @@ bool Pickle::ReadString16(void** iter, string16* result) const {
|
|||
bool Pickle::ReadBytes(void** iter, const char** data, int length) const {
|
||||
DCHECK(iter);
|
||||
DCHECK(data);
|
||||
if (!*iter)
|
||||
*iter = const_cast<char*>(payload());
|
||||
|
||||
if (!IteratorHasRoomFor(*iter, length))
|
||||
return false;
|
||||
|
@ -251,6 +303,8 @@ bool Pickle::ReadData(void** iter, const char** data, int* length) const {
|
|||
DCHECK(iter);
|
||||
DCHECK(data);
|
||||
DCHECK(length);
|
||||
if (!*iter)
|
||||
*iter = const_cast<char*>(payload());
|
||||
|
||||
if (!ReadLength(iter, length))
|
||||
return false;
|
||||
|
|
|
@ -65,8 +65,12 @@ class Pickle {
|
|||
// true. Otherwise, false is returned to indicate that the result could not
|
||||
// be extracted.
|
||||
bool ReadBool(void** iter, bool* result) const;
|
||||
bool ReadInt16(void** iter, int16* result) const;
|
||||
bool ReadUInt16(void** iter, uint16* result) const;
|
||||
bool ReadShort(void** iter, short* result) const;
|
||||
bool ReadInt(void** iter, int* result) const;
|
||||
bool ReadLong(void** iter, long* result) const;
|
||||
bool ReadULong(void** iter, unsigned long* result) const;
|
||||
bool ReadSize(void** iter, size_t* result) const;
|
||||
bool ReadUInt32(void** iter, uint32* result) const;
|
||||
bool ReadInt64(void** iter, int64* result) const;
|
||||
|
@ -88,12 +92,21 @@ class Pickle {
|
|||
bool WriteBool(bool value) {
|
||||
return WriteInt(value ? 1 : 0);
|
||||
}
|
||||
bool WriteInt16(int16 value) {
|
||||
return WriteBytes(&value, sizeof(value));
|
||||
}
|
||||
bool WriteUInt16(uint16 value) {
|
||||
return WriteBytes(&value, sizeof(value));
|
||||
}
|
||||
bool WriteInt(int value) {
|
||||
return WriteBytes(&value, sizeof(value));
|
||||
}
|
||||
bool WriteLong(long value) {
|
||||
return WriteBytes(&value, sizeof(value));
|
||||
}
|
||||
bool WriteULong(unsigned long value) {
|
||||
return WriteBytes(&value, sizeof(value));
|
||||
}
|
||||
bool WriteSize(size_t value) {
|
||||
return WriteBytes(&value, sizeof(value));
|
||||
}
|
||||
|
|
|
@ -331,6 +331,9 @@ bool IsWprintfFormatPortable(const wchar_t* format) {
|
|||
|
||||
} // namespace base
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
namespace base {
|
||||
#endif
|
||||
|
||||
const std::string& EmptyString() {
|
||||
return Singleton<EmptyStrings>::get()->s;
|
||||
|
@ -344,6 +347,10 @@ const string16& EmptyString16() {
|
|||
return Singleton<EmptyStrings>::get()->s16;
|
||||
}
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
}
|
||||
#endif
|
||||
|
||||
const wchar_t kWhitespaceWide[] = {
|
||||
0x0009, // <control-0009> to <control-000D>
|
||||
0x000A,
|
||||
|
|
|
@ -107,6 +107,9 @@ bool IsWprintfFormatPortable(const wchar_t* format);
|
|||
#error Define string operations appropriately for your platform
|
||||
#endif
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
namespace base {
|
||||
#endif
|
||||
// Returns a reference to a globally unique empty string that functions can
|
||||
// return. Use this to avoid static construction of strings, not to replace
|
||||
// any and all uses of "std::string()" as nicer-looking sugar.
|
||||
|
@ -114,6 +117,9 @@ bool IsWprintfFormatPortable(const wchar_t* format);
|
|||
const std::string& EmptyString();
|
||||
const std::wstring& EmptyWString();
|
||||
const string16& EmptyString16();
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
}
|
||||
#endif
|
||||
|
||||
extern const wchar_t kWhitespaceWide[];
|
||||
extern const char kWhitespaceASCII[];
|
||||
|
|
|
@ -62,6 +62,8 @@
|
|||
#endif
|
||||
|
||||
// Type detection for wchar_t.
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#define WCHAR_T_IS_UTF16
|
||||
#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \
|
||||
|
@ -72,4 +74,22 @@
|
|||
#error Please add support for your compiler in build/build_config.h
|
||||
#endif
|
||||
|
||||
#else // CHROMIUM_MOZILLA_BUILD
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#define WCHAR_T_IS_UTF16
|
||||
#elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__)
|
||||
#if (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff)
|
||||
#define WCHAR_T_IS_UTF32
|
||||
#elif (__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff)
|
||||
#define WCHAR_T_IS_UTF16
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(WCHAR_T_IS_UTF16) && !defined(WCHAR_T_IS_UTF32)
|
||||
#error Please add support for your compiler in build/build_config.h
|
||||
#endif
|
||||
|
||||
#endif // CHROMIUM_MOZILLA_BUILD
|
||||
|
||||
#endif // BUILD_BUILD_CONFIG_H_
|
||||
|
|
|
@ -10,11 +10,18 @@
|
|||
#include "base/process_util.h"
|
||||
#include "base/singleton.h"
|
||||
#include "base/waitable_event.h"
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
#include "mozilla/ipc/GeckoThread.h"
|
||||
typedef mozilla::ipc::BrowserProcessSubThread ChromeThread;
|
||||
#else
|
||||
#include "chrome/browser/chrome_thread.h"
|
||||
#endif
|
||||
#include "chrome/common/ipc_logging.h"
|
||||
#include "chrome/common/notification_service.h"
|
||||
#include "chrome/common/notification_type.h"
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
#include "chrome/common/plugin_messages.h"
|
||||
#endif
|
||||
#include "chrome/common/process_watcher.h"
|
||||
#include "chrome/common/result_codes.h"
|
||||
|
||||
|
@ -48,7 +55,12 @@ class ChildNotificationTask : public Task {
|
|||
|
||||
ChildProcessHost::ChildProcessHost(
|
||||
ProcessType type, ResourceDispatcherHost* resource_dispatcher_host)
|
||||
: Receiver(type),
|
||||
:
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
ChildProcessInfo(type),
|
||||
#else
|
||||
Receiver(type),
|
||||
#endif
|
||||
ALLOW_THIS_IN_INITIALIZER_LIST(listener_(this)),
|
||||
resource_dispatcher_host_(resource_dispatcher_host),
|
||||
opening_channel_(false),
|
||||
|
@ -107,7 +119,11 @@ bool ChildProcessHost::Send(IPC::Message* msg) {
|
|||
}
|
||||
|
||||
void ChildProcessHost::Notify(NotificationType type) {
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
ChromeThread::GetMessageLoop(ChromeThread::IO)->PostTask(
|
||||
#else
|
||||
resource_dispatcher_host_->ui_loop()->PostTask(
|
||||
#endif
|
||||
FROM_HERE, new ChildNotificationTask(type, this));
|
||||
}
|
||||
|
||||
|
@ -147,16 +163,24 @@ void ChildProcessHost::ListenerHook::OnMessageReceived(
|
|||
#endif
|
||||
|
||||
bool msg_is_ok = true;
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
bool handled = false;
|
||||
#else
|
||||
bool handled = host_->resource_dispatcher_host_->OnMessageReceived(
|
||||
msg, host_, &msg_is_ok);
|
||||
#endif
|
||||
|
||||
if (!handled) {
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
if (0) {
|
||||
#else
|
||||
if (msg.type() == PluginProcessHostMsg_ShutdownRequest::ID) {
|
||||
// Must remove the process from the list now, in case it gets used for a
|
||||
// new instance before our watcher tells us that the process terminated.
|
||||
Singleton<ChildProcessList>::get()->remove(host_);
|
||||
if (host_->CanShutdown())
|
||||
host_->Send(new PluginProcessMsg_Shutdown());
|
||||
#endif
|
||||
} else {
|
||||
host_->OnMessageReceived(msg);
|
||||
}
|
||||
|
@ -174,7 +198,9 @@ void ChildProcessHost::ListenerHook::OnMessageReceived(
|
|||
void ChildProcessHost::ListenerHook::OnChannelConnected(int32 peer_pid) {
|
||||
host_->opening_channel_ = false;
|
||||
host_->OnChannelConnected(peer_pid);
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
host_->Send(new PluginProcessMsg_AskBeforeShutdown());
|
||||
#endif
|
||||
|
||||
// Notify in the main loop of the connection.
|
||||
host_->Notify(NotificationType::CHILD_PROCESS_HOST_CONNECTED);
|
||||
|
@ -187,17 +213,21 @@ void ChildProcessHost::ListenerHook::OnChannelError() {
|
|||
|
||||
|
||||
ChildProcessHost::Iterator::Iterator() : all_(true) {
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
DCHECK(MessageLoop::current() ==
|
||||
ChromeThread::GetMessageLoop(ChromeThread::IO)) <<
|
||||
"ChildProcessInfo::Iterator must be used on the IO thread.";
|
||||
#endif
|
||||
iterator_ = Singleton<ChildProcessList>::get()->begin();
|
||||
}
|
||||
|
||||
ChildProcessHost::Iterator::Iterator(ProcessType type)
|
||||
: all_(false), type_(type) {
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
DCHECK(MessageLoop::current() ==
|
||||
ChromeThread::GetMessageLoop(ChromeThread::IO)) <<
|
||||
"ChildProcessInfo::Iterator must be used on the IO thread.";
|
||||
#endif
|
||||
iterator_ = Singleton<ChildProcessList>::get()->begin();
|
||||
if (!Done() && (*iterator_)->type() != type_)
|
||||
++(*this);
|
||||
|
|
|
@ -12,7 +12,11 @@
|
|||
#include "base/basictypes.h"
|
||||
#include "base/scoped_ptr.h"
|
||||
#include "base/waitable_event_watcher.h"
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
class ResourceDispatcherHost;
|
||||
#else
|
||||
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
|
||||
#endif
|
||||
#include "chrome/common/child_process_info.h"
|
||||
#include "chrome/common/ipc_channel.h"
|
||||
|
||||
|
@ -20,7 +24,13 @@ class NotificationType;
|
|||
|
||||
// Plugins/workers and other child processes that live on the IO thread should
|
||||
// derive from this class.
|
||||
class ChildProcessHost : public ResourceDispatcherHost::Receiver,
|
||||
class ChildProcessHost :
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
public IPC::Message::Sender,
|
||||
public ChildProcessInfo,
|
||||
#else
|
||||
public ResourceDispatcherHost::Receiver,
|
||||
#endif
|
||||
public base::WaitableEventWatcher::Delegate,
|
||||
public IPC::Channel::Listener {
|
||||
public:
|
||||
|
@ -51,7 +61,7 @@ class ChildProcessHost : public ResourceDispatcherHost::Receiver,
|
|||
|
||||
protected:
|
||||
ChildProcessHost(ProcessType type,
|
||||
ResourceDispatcherHost* resource_dispatcher_host);
|
||||
ResourceDispatcherHost* resource_dispatcher_host = 0);
|
||||
|
||||
// Derived classes return true if it's ok to shut down the child process.
|
||||
virtual bool CanShutdown() = 0;
|
||||
|
@ -74,7 +84,14 @@ class ChildProcessHost : public ResourceDispatcherHost::Receiver,
|
|||
bool opening_channel() { return opening_channel_; }
|
||||
const std::wstring& channel_id() { return channel_id_; }
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
base::WaitableEvent* GetProcessEvent() { return process_event_.get(); }
|
||||
#endif
|
||||
|
||||
const IPC::Channel& channel() const { return *channel_; }
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
IPC::Channel* channelp() const { return channel_.get(); }
|
||||
#endif
|
||||
|
||||
private:
|
||||
// Sends the given notification to the notification service on the UI thread.
|
||||
|
|
|
@ -6,12 +6,16 @@
|
|||
|
||||
#include <limits>
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
#include "app/l10n_util.h"
|
||||
#endif
|
||||
#include "base/logging.h"
|
||||
#include "base/process_util.h"
|
||||
#include "base/rand_util.h"
|
||||
#include "base/string_util.h"
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
#include "grit/generated_resources.h"
|
||||
#endif
|
||||
|
||||
std::wstring ChildProcessInfo::GetTypeNameInEnglish(
|
||||
ChildProcessInfo::ProcessType type) {
|
||||
|
@ -32,6 +36,9 @@ std::wstring ChildProcessInfo::GetTypeNameInEnglish(
|
|||
}
|
||||
|
||||
std::wstring ChildProcessInfo::GetLocalizedTitle() const {
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
return name_;
|
||||
#else
|
||||
std::wstring title = name_;
|
||||
if (type_ == ChildProcessInfo::PLUGIN_PROCESS && title.empty())
|
||||
title = l10n_util::GetString(IDS_TASK_MANAGER_UNKNOWN_PLUGIN_NAME);
|
||||
|
@ -52,6 +59,7 @@ std::wstring ChildProcessInfo::GetLocalizedTitle() const {
|
|||
// or Arabic word for "plugin".
|
||||
l10n_util::AdjustStringForLocaleDirection(title, &title);
|
||||
return l10n_util::GetStringF(message_id, title);
|
||||
#endif
|
||||
}
|
||||
|
||||
ChildProcessInfo::ChildProcessInfo(ProcessType type) {
|
||||
|
|
|
@ -9,9 +9,10 @@
|
|||
#include "chrome/common/child_process.h"
|
||||
#include "chrome/common/chrome_switches.h"
|
||||
#include "chrome/common/ipc_logging.h"
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
#include "chrome/common/plugin_messages.h"
|
||||
#include "webkit/glue/webkit_glue.h"
|
||||
|
||||
#endif
|
||||
|
||||
// V8 needs a 1MB stack size.
|
||||
const size_t ChildThread::kV8StackSize = 1024 * 1024;
|
||||
|
@ -26,9 +27,11 @@ ChildThread::ChildThread(Thread::Options options)
|
|||
switches::kProcessChannelID);
|
||||
|
||||
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUserAgent)) {
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
webkit_glue::SetUserAgent(WideToUTF8(
|
||||
CommandLine::ForCurrentProcess()->GetSwitchValue(
|
||||
switches::kUserAgent)));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,6 +68,7 @@ void ChildThread::RemoveRoute(int32 routing_id) {
|
|||
}
|
||||
|
||||
void ChildThread::OnMessageReceived(const IPC::Message& msg) {
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
// Resource responses are sent to the resource dispatcher.
|
||||
if (resource_dispatcher_->OnMessageReceived(msg))
|
||||
return;
|
||||
|
@ -78,6 +82,7 @@ void ChildThread::OnMessageReceived(const IPC::Message& msg) {
|
|||
owner_loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask());
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (msg.routing_id() == MSG_ROUTING_CONTROL) {
|
||||
OnControlMessageReceived(msg);
|
||||
|
@ -91,14 +96,23 @@ ChildThread* ChildThread::current() {
|
|||
}
|
||||
|
||||
void ChildThread::Init() {
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
channel_.reset(new IPC::SyncChannel(channel_name_,
|
||||
IPC::Channel::MODE_CLIENT, this, NULL, owner_loop_, true,
|
||||
ChildProcess::current()->GetShutDownEvent()));
|
||||
#else
|
||||
channel_.reset(new IPC::Channel(channel_name_,
|
||||
IPC::Channel::MODE_CLIENT,
|
||||
this));
|
||||
#endif
|
||||
|
||||
#ifdef IPC_MESSAGE_LOG_ENABLED
|
||||
IPC::Logging::current()->SetIPCSender(this);
|
||||
#endif
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
resource_dispatcher_.reset(new ResourceDispatcher(this));
|
||||
#endif
|
||||
}
|
||||
|
||||
void ChildThread::CleanUp() {
|
||||
|
@ -108,7 +122,9 @@ void ChildThread::CleanUp() {
|
|||
// Need to destruct the SyncChannel to the browser before we go away because
|
||||
// it caches a pointer to this thread.
|
||||
channel_.reset();
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
resource_dispatcher_.reset();
|
||||
#endif
|
||||
}
|
||||
|
||||
void ChildThread::OnProcessFinalRelease() {
|
||||
|
@ -117,9 +133,11 @@ void ChildThread::OnProcessFinalRelease() {
|
|||
return;
|
||||
}
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
// The child process shutdown sequence is a request response based mechanism,
|
||||
// where we send out an initial feeler request to the child process host
|
||||
// instance in the browser to verify if it's ok to shutdown the child process.
|
||||
// The browser then sends back a response if it's ok to shutdown.
|
||||
Send(new PluginProcessHostMsg_ShutdownRequest);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -8,7 +8,12 @@
|
|||
#include "base/thread.h"
|
||||
#include "chrome/common/ipc_sync_channel.h"
|
||||
#include "chrome/common/message_router.h"
|
||||
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
class ResourceDispatcher;
|
||||
#else
|
||||
#include "chrome/common/resource_dispatcher.h"
|
||||
#endif
|
||||
|
||||
// Child processes's background thread should derive from this class.
|
||||
class ChildThread : public IPC::Channel::Listener,
|
||||
|
@ -28,9 +33,11 @@ class ChildThread : public IPC::Channel::Listener,
|
|||
|
||||
MessageLoop* owner_loop() { return owner_loop_; }
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
ResourceDispatcher* resource_dispatcher() {
|
||||
return resource_dispatcher_.get();
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
friend class ChildProcess;
|
||||
|
@ -53,7 +60,11 @@ class ChildThread : public IPC::Channel::Listener,
|
|||
// Returns the one child thread.
|
||||
static ChildThread* current();
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
IPC::SyncChannel* channel() { return channel_.get(); }
|
||||
#else
|
||||
IPC::Channel* channel() { return channel_.get(); }
|
||||
#endif
|
||||
|
||||
// Thread implementation.
|
||||
virtual void Init();
|
||||
|
@ -68,7 +79,11 @@ class ChildThread : public IPC::Channel::Listener,
|
|||
MessageLoop* owner_loop_;
|
||||
|
||||
std::wstring channel_name_;
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
scoped_ptr<IPC::SyncChannel> channel_;
|
||||
#else
|
||||
scoped_ptr<IPC::Channel> channel_;
|
||||
#endif
|
||||
|
||||
// Used only on the background render thread to implement message routing
|
||||
// functionality to the consumers of the ChildThread.
|
||||
|
@ -76,9 +91,11 @@ class ChildThread : public IPC::Channel::Listener,
|
|||
|
||||
Thread::Options options_;
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
// Handles resource loads for this process.
|
||||
// NOTE: this object lives on the owner thread.
|
||||
scoped_ptr<ResourceDispatcher> resource_dispatcher_;
|
||||
#endif
|
||||
|
||||
// If true, checks with the browser process before shutdown. This avoids race
|
||||
// conditions if the process refcount is 0 but there's an IPC message inflight
|
||||
|
|
|
@ -127,7 +127,11 @@ bool PathProvider(int key, FilePath* result) {
|
|||
case chrome::FILE_LOCAL_STATE:
|
||||
if (!PathService::Get(chrome::DIR_USER_DATA, &cur))
|
||||
return false;
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
cur = cur.Append(FILE_PATH_LITERAL("Local State"));
|
||||
#else
|
||||
cur = cur.Append(chrome::kLocalStateFilename);
|
||||
#endif
|
||||
break;
|
||||
case chrome::FILE_RECORDED_SCRIPT:
|
||||
if (!PathService::Get(chrome::DIR_USER_DATA, &cur))
|
||||
|
|
|
@ -9,7 +9,9 @@
|
|||
|
||||
#include "base/file_path.h"
|
||||
#include "base/path_service.h"
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
#include "chrome/third_party/xdg_user_dirs/xdg_user_dir_lookup.h"
|
||||
#endif // ifndef CHROMIUM_MOZILLA_BUILD
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -34,12 +36,14 @@ FilePath GetHomeDir() {
|
|||
// Wrapper around xdg_user_dir_lookup() from
|
||||
// src/chrome/third_party/xdg-user-dirs
|
||||
FilePath GetXDGUserDirectory(const char* env_name, const char* fallback_dir) {
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
char* xdg_dir = xdg_user_dir_lookup(env_name);
|
||||
if (xdg_dir) {
|
||||
FilePath rv(xdg_dir);
|
||||
free(xdg_dir);
|
||||
return rv;
|
||||
}
|
||||
#endif // ifndef CHROMIUM_MOZILLA_BUILD
|
||||
return GetHomeDir().Append(fallback_dir);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
#ifndef CHROME_COMMON_ENV_VARS_H__
|
||||
#define CHROME_COMMON_ENV_VARS_H__
|
||||
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD) && defined(COMPILER_MSVC)
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
namespace env_vars {
|
||||
|
||||
extern const wchar_t kHeadless[];
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "chrome/common/ipc_sync_message.h"
|
||||
#include "chrome/common/ipc_message_utils.h"
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
// This include list should contain all _messages.h header files so that they
|
||||
// can get *MsgLog function etc. This makes ipc logs much more informative.
|
||||
#include "chrome/common/render_messages.h"
|
||||
|
@ -35,6 +36,8 @@
|
|||
#include "chrome/common/plugin_messages.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(OS_POSIX)
|
||||
#include "base/string_util.h"
|
||||
#include <unistd.h>
|
||||
|
@ -98,7 +101,7 @@ Logging::Logging()
|
|||
CreateEvent(NULL, TRUE, FALSE, event_name.c_str())));
|
||||
|
||||
RegisterWaitForEvent(true);
|
||||
#elif defined(OS_POSIX)
|
||||
#elif (!defined(CHROMIUM_MOZILLA_BUILD) && defined(OS_POSIX))
|
||||
if (getenv("CHROME_IPC_LOGGING"))
|
||||
enabled_ = true;
|
||||
SetLoggerFunctions(g_log_function_mapping);
|
||||
|
|
|
@ -40,7 +40,11 @@
|
|||
// ViewHostMsg_SyncMessageName::WriteReplyParams(reply_msg, out1, out2);
|
||||
// Send(reply_msg);
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
#include "IPC/IPCMessageUtils.h"
|
||||
#else
|
||||
#include "chrome/common/ipc_message_utils.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef MESSAGES_INTERNAL_FILE
|
||||
|
|
|
@ -5,11 +5,15 @@
|
|||
#include "chrome/common/ipc_message_utils.h"
|
||||
|
||||
#include "base/gfx/rect.h"
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
#include "googleurl/src/gurl.h"
|
||||
#endif
|
||||
#ifndef EXCLUDE_SKIA_DEPENDENCIES
|
||||
#include "SkBitmap.h"
|
||||
#endif
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
#include "webkit/glue/dom_operations.h"
|
||||
#endif
|
||||
|
||||
namespace IPC {
|
||||
|
||||
|
@ -96,6 +100,7 @@ void ParamTraits<SkBitmap>::Log(const SkBitmap& p, std::wstring* l) {
|
|||
|
||||
#endif // EXCLUDE_SKIA_DEPENDENCIES
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
void ParamTraits<GURL>::Write(Message* m, const GURL& p) {
|
||||
m->WriteString(p.possibly_invalid_spec());
|
||||
// TODO(brettw) bug 684583: Add encoding for query params.
|
||||
|
@ -221,4 +226,6 @@ void ParamTraits<webkit_glue::WebApplicationInfo>::Log(
|
|||
l->append(L"<WebApplicationInfo>");
|
||||
}
|
||||
|
||||
#endif // CHROMIUM_MOZILLA_BUILD
|
||||
|
||||
} // namespace IPC
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "chrome/common/ipc_sync_message.h"
|
||||
#include "chrome/common/thumbnail_score.h"
|
||||
#include "chrome/common/transport_dib.h"
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
#include "webkit/glue/webcursor.h"
|
||||
#include "webkit/glue/window_open_disposition.h"
|
||||
|
||||
|
@ -67,6 +68,8 @@ enum IPCMessageStart {
|
|||
|
||||
COMPILE_ASSERT(LastMsgIndex <= 16, need_to_update_IPC_MESSAGE_MACRO);
|
||||
|
||||
#endif /* CHROMIUM_MOZILLA_BUILD */
|
||||
|
||||
namespace IPC {
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -145,6 +148,34 @@ struct ParamTraits<bool> {
|
|||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<int16> {
|
||||
typedef int16 param_type;
|
||||
static void Write(Message* m, const param_type& p) {
|
||||
m->WriteInt(p);
|
||||
}
|
||||
static bool Read(const Message* m, void** iter, param_type* r) {
|
||||
return m->ReadInt16(iter, r);
|
||||
}
|
||||
static void Log(const param_type& p, std::wstring* l) {
|
||||
l->append(StringPrintf(L"%hd", p));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<uint16> {
|
||||
typedef uint16 param_type;
|
||||
static void Write(Message* m, const param_type& p) {
|
||||
m->WriteInt(p);
|
||||
}
|
||||
static bool Read(const Message* m, void** iter, param_type* r) {
|
||||
return m->ReadUInt16(iter, r);
|
||||
}
|
||||
static void Log(const param_type& p, std::wstring* l) {
|
||||
l->append(StringPrintf(L"%hu", p));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<int> {
|
||||
typedef int param_type;
|
||||
|
@ -173,6 +204,20 @@ struct ParamTraits<long> {
|
|||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<unsigned long> {
|
||||
typedef unsigned long param_type;
|
||||
static void Write(Message* m, const param_type& p) {
|
||||
m->WriteULong(p);
|
||||
}
|
||||
static bool Read(const Message* m, void** iter, param_type* r) {
|
||||
return m->ReadULong(iter, r);
|
||||
}
|
||||
static void Log(const param_type& p, std::wstring* l) {
|
||||
l->append(StringPrintf(L"%ul", p));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<size_t> {
|
||||
typedef size_t param_type;
|
||||
|
@ -257,6 +302,7 @@ struct ParamTraits<double> {
|
|||
}
|
||||
};
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
template <>
|
||||
struct ParamTraits<wchar_t> {
|
||||
typedef wchar_t param_type;
|
||||
|
@ -280,6 +326,7 @@ struct ParamTraits<wchar_t> {
|
|||
l->append(StringPrintf(L"%lc", p));
|
||||
}
|
||||
};
|
||||
#endif /* CHROMIUM_MOZILLA_BUILD */
|
||||
|
||||
template <>
|
||||
struct ParamTraits<base::Time> {
|
||||
|
@ -346,6 +393,7 @@ struct ParamTraits<MSG> {
|
|||
};
|
||||
#endif // defined(OS_WIN)
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
template <>
|
||||
struct ParamTraits<SkBitmap> {
|
||||
typedef SkBitmap param_type;
|
||||
|
@ -357,6 +405,7 @@ struct ParamTraits<SkBitmap> {
|
|||
|
||||
static void Log(const param_type& p, std::wstring* l);
|
||||
};
|
||||
#endif /* CHROMIUM_MOZILLA_BUILD */
|
||||
|
||||
template <>
|
||||
struct ParamTraits<std::string> {
|
||||
|
@ -527,6 +576,7 @@ struct ParamTraits<string16> {
|
|||
};
|
||||
#endif
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
template <>
|
||||
struct ParamTraits<GURL> {
|
||||
typedef GURL param_type;
|
||||
|
@ -534,6 +584,7 @@ struct ParamTraits<GURL> {
|
|||
static bool Read(const Message* m, void** iter, param_type* p);
|
||||
static void Log(const param_type& p, std::wstring* l);
|
||||
};
|
||||
#endif /* CHROMIUM_MOZILLA_BUILD */
|
||||
|
||||
// and, a few more useful types...
|
||||
#if defined(OS_WIN)
|
||||
|
@ -633,6 +684,7 @@ struct ParamTraits<FilePath> {
|
|||
}
|
||||
};
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
template <>
|
||||
struct ParamTraits<gfx::Point> {
|
||||
typedef gfx::Point param_type;
|
||||
|
@ -656,6 +708,7 @@ struct ParamTraits<gfx::Size> {
|
|||
static bool Read(const Message* m, void** iter, param_type* r);
|
||||
static void Log(const param_type& p, std::wstring* l);
|
||||
};
|
||||
#endif /* CHROMIUM_MOZILLA_BUILD */
|
||||
|
||||
#if defined(OS_POSIX)
|
||||
// FileDescriptors may be serialised over IPC channels on POSIX. On the
|
||||
|
@ -739,6 +792,7 @@ struct ParamTraits<ThumbnailScore> {
|
|||
}
|
||||
};
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
template <>
|
||||
struct ParamTraits<WindowOpenDisposition> {
|
||||
typedef WindowOpenDisposition param_type;
|
||||
|
@ -755,6 +809,7 @@ struct ParamTraits<WindowOpenDisposition> {
|
|||
l->append(StringPrintf(L"%d", p));
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(OS_WIN)
|
||||
template <>
|
||||
|
@ -782,6 +837,7 @@ struct ParamTraits<XFORM> {
|
|||
};
|
||||
#endif // defined(OS_WIN)
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
template <>
|
||||
struct ParamTraits<WebCursor> {
|
||||
typedef WebCursor param_type;
|
||||
|
@ -795,6 +851,7 @@ struct ParamTraits<WebCursor> {
|
|||
l->append(L"<WebCursor>");
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
struct LogData {
|
||||
std::wstring channel;
|
||||
|
@ -842,7 +899,7 @@ struct ParamTraits<LogData> {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
template <>
|
||||
struct ParamTraits<webkit_glue::WebApplicationInfo> {
|
||||
typedef webkit_glue::WebApplicationInfo param_type;
|
||||
|
@ -850,7 +907,7 @@ struct ParamTraits<webkit_glue::WebApplicationInfo> {
|
|||
static bool Read(const Message* m, void** iter, param_type* r);
|
||||
static void Log(const param_type& p, std::wstring* l);
|
||||
};
|
||||
|
||||
#endif /* CHROMIUM_MOZILLA_BUILD */
|
||||
|
||||
#if defined(OS_WIN)
|
||||
template<>
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
#include "chrome/common/message_router.h"
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
#include "chrome/common/render_messages.h"
|
||||
#endif
|
||||
|
||||
void MessageRouter::OnControlMessageReceived(const IPC::Message& msg) {
|
||||
NOTREACHED() <<
|
||||
|
|
|
@ -6,12 +6,16 @@
|
|||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
#include "app/l10n_util.h"
|
||||
#endif
|
||||
#include "base/file_path.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/sys_string_conversions.h"
|
||||
#ifndef CHROMIUM_MOZILLA_BUILD
|
||||
#include "chrome/browser/cocoa/tab_window_controller.h"
|
||||
#include "grit/generated_resources.h"
|
||||
#endif
|
||||
|
||||
namespace platform_util {
|
||||
|
||||
|
@ -26,6 +30,10 @@ gfx::NativeWindow GetTopLevel(gfx::NativeView view) {
|
|||
}
|
||||
|
||||
string16 GetWindowTitle(gfx::NativeWindow window) {
|
||||
#ifdef CHROMIUM_MOZILLA_BUILD
|
||||
std::string str("Untitled");
|
||||
return string16(str.begin(), str.end());
|
||||
#else
|
||||
NSString* title = nil;
|
||||
if ([[window delegate] isKindOfClass:[TabWindowController class]])
|
||||
title = [[window delegate] selectedTabTitle];
|
||||
|
@ -37,6 +45,7 @@ string16 GetWindowTitle(gfx::NativeWindow window) {
|
|||
IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED));
|
||||
|
||||
return base::SysNSStringToUTF16(title);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool IsWindowActive(gfx::NativeWindow window) {
|
||||
|
|
|
@ -4,9 +4,7 @@
|
|||
|
||||
#include "base/shared_memory.h"
|
||||
#include "chrome/common/ipc_message_macros.h"
|
||||
#include "webkit/glue/webcursor.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// PluginProcess messages
|
||||
// These are messages sent from the browser to the plugin process.
|
||||
IPC_BEGIN_MESSAGES(PluginProcess)
|
||||
|
|
Загрузка…
Ссылка в новой задаче