diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in index 393facdab411..f2e733bc00d1 100644 --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -180,6 +180,7 @@ @BINPATH@/components/inspector.xpt @BINPATH@/components/intl.xpt @BINPATH@/components/jar.xpt +@BINPATH@/components/jetpack.xpt @BINPATH@/components/jsdservice.xpt @BINPATH@/components/layout_base.xpt #ifdef NS_PRINTING diff --git a/ipc/ipdl/Makefile.in b/ipc/ipdl/Makefile.in index 8e95f03314c8..487894a62c14 100644 --- a/ipc/ipdl/Makefile.in +++ b/ipc/ipdl/Makefile.in @@ -55,6 +55,7 @@ EXPORT_LIBRARY = 1 ## IPDLDIRS = \ dom/plugins \ + js/jetpack \ ipc/ipdl/test/cxx \ $(NULL) ##----------------------------------------------------------------------------- diff --git a/js/jetpack/JetpackChild.cpp b/js/jetpack/JetpackChild.cpp new file mode 100644 index 000000000000..8aef63188e34 --- /dev/null +++ b/js/jetpack/JetpackChild.cpp @@ -0,0 +1,83 @@ +/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Firefox. + * + * The Initial Developer of the Original Code is + * the Mozilla Foundation . + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "mozilla/jetpack/JetpackChild.h" + +#include + +namespace mozilla { +namespace jetpack { + +JetpackChild::JetpackChild() +{ + NS_ASSERTION(!gInstance, "Something terribly wrong here!"); + gInstance = this; +} + +JetpackChild::~JetpackChild() +{ + NS_ASSERTION(gInstance == this, "Something terribly wrong here!"); + gInstance = nsnull; +} + +bool +JetpackChild::Init(base::ProcessHandle aParentProcessHandle, + MessageLoop* aIOLoop, + IPC::Channel* aChannel) +{ + if (!Open(aChannel, aParentProcessHandle, aIOLoop)) + return false; + + return true; +} + +void +JetpackChild::CleanUp() +{ +} + +bool +JetpackChild::RecvLoadImplementation(const nsCString& script) +{ + printf("Received LoadImplementation message: '%s'\n", script.get()); + return true; +} + +JetpackChild* JetpackChild::gInstance; + +} // namespace jetpack +} // namespace mozilla diff --git a/js/jetpack/JetpackChild.h b/js/jetpack/JetpackChild.h new file mode 100644 index 000000000000..b571abfbb805 --- /dev/null +++ b/js/jetpack/JetpackChild.h @@ -0,0 +1,73 @@ +/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Firefox. + * + * The Initial Developer of the Original Code is + * the Mozilla Foundation . + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef mozilla_jetpack_JetpackChild_h +#define mozilla_jetpack_JetpackChild_h + +#include "mozilla/jetpack/PJetpackChild.h" + +namespace mozilla { +namespace jetpack { + +class JetpackChild : public PJetpackChild +{ +public: + JetpackChild(); + ~JetpackChild(); + + static JetpackChild* current(); + + bool Init(base::ProcessHandle aParentProcessHandle, + MessageLoop* aIOLoop, + IPC::Channel* aChannel); + + void CleanUp(); + +protected: + NS_OVERRIDE virtual bool RecvLoadImplementation(const nsCString& script); + +private: + static JetpackChild* gInstance; + + DISALLOW_EVIL_CONSTRUCTORS(JetpackChild); +}; + +} // namespace jetpack +} // namespace mozilla + + +#endif // mozilla_jetpack_JetpackChild_h diff --git a/js/jetpack/JetpackParent.cpp b/js/jetpack/JetpackParent.cpp new file mode 100644 index 000000000000..1bc1c7abc5bb --- /dev/null +++ b/js/jetpack/JetpackParent.cpp @@ -0,0 +1,70 @@ +/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Firefox. + * + * The Initial Developer of the Original Code is + * the Mozilla Foundation . + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "mozilla/jetpack/JetpackParent.h" + +namespace mozilla { +namespace jetpack { + +JetpackParent::JetpackParent() + : mSubprocess(new JetpackProcessParent()) +{ + mSubprocess->Launch(); + Open(mSubprocess->GetChannel(), + mSubprocess->GetChildProcessHandle()); +} + +JetpackParent::~JetpackParent() +{ + XRE_GetIOMessageLoop() + ->PostTask(FROM_HERE, new DeleteTask(mSubprocess)); +} + +NS_IMPL_ISUPPORTS1(JetpackParent, nsIJetpack) + +NS_IMETHODIMP +JetpackParent::LoadImplementation(const nsAString& aURI) +{ + // this is all wrong, load the URI and send the data, but for now... + if (!SendLoadImplementation(NS_ConvertUTF16toUTF8(aURI))) + return NS_ERROR_FAILURE; + + return NS_OK; +} + +} // namespace jetpack +} // namespace mozilla diff --git a/js/jetpack/JetpackParent.h b/js/jetpack/JetpackParent.h new file mode 100644 index 000000000000..697a82021662 --- /dev/null +++ b/js/jetpack/JetpackParent.h @@ -0,0 +1,68 @@ +/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Firefox. + * + * The Initial Developer of the Original Code is + * the Mozilla Foundation . + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef mozilla_jetpack_JetpackParent_h +#define mozilla_jetpack_JetpackParent_h + +#include "mozilla/jetpack/PJetpackParent.h" +#include "mozilla/jetpack/JetpackProcessParent.h" +#include "nsIJetpack.h" + +namespace mozilla { +namespace jetpack { + +class JetpackParent + : public PJetpackParent + , public nsIJetpack +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIJETPACK + + JetpackParent(); + ~JetpackParent(); + +private: + JetpackProcessParent* mSubprocess; + + DISALLOW_EVIL_CONSTRUCTORS(JetpackParent); +}; + +} // namespace jetpack +} // namespace mozilla + +#endif // mozilla_jetpack_JetpackParent_h diff --git a/js/jetpack/JetpackProcessChild.cpp b/js/jetpack/JetpackProcessChild.cpp new file mode 100644 index 000000000000..c2b399fbdeaa --- /dev/null +++ b/js/jetpack/JetpackProcessChild.cpp @@ -0,0 +1,63 @@ +/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Firefox. + * + * The Initial Developer of the Original Code is + * the Mozilla Foundation . + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "mozilla/ipc/IOThreadChild.h" + +#include "mozilla/jetpack/JetpackProcessChild.h" + +using mozilla::ipc::IOThreadChild; + +namespace mozilla { +namespace jetpack { + +bool +JetpackProcessChild::Init() +{ + mJetpack.Init(ParentHandle(), + IOThreadChild::message_loop(), + IOThreadChild::channel()); + return true; +} + +void +JetpackProcessChild::CleanUp() +{ + mJetpack.CleanUp(); +} + +} // namespace jetpack +} // namespace mozilla diff --git a/js/jetpack/JetpackProcessChild.h b/js/jetpack/JetpackProcessChild.h new file mode 100644 index 000000000000..3941663f01fa --- /dev/null +++ b/js/jetpack/JetpackProcessChild.h @@ -0,0 +1,79 @@ +/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Firefox. + * + * The Initial Developer of the Original Code is + * the Mozilla Foundation . + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef mozilla_jetpack_JetpackProcessChild_h +#define mozilla_jetpack_JetpackProcessChild_h + +#include "mozilla/ipc/ProcessChild.h" + +#include "mozilla/jetpack/JetpackChild.h" + +namespace mozilla { +namespace jetpack { + +// The JetpackProcessChild class represents the thread where jetpack code is run; +// the main() thread is the I/O thread of the jetpack process. + +class JetpackProcessChild : public mozilla::ipc::ProcessChild +{ + typedef mozilla::ipc::ProcessChild ProcessChild; + +public: + JetpackProcessChild(ProcessHandle aParentHandle) + : ProcessChild(aParentHandle) + { } + + virtual ~JetpackProcessChild() + { } + + NS_OVERRIDE virtual bool Init(); + NS_OVERRIDE virtual void CleanUp(); + + static JetpackProcessChild* current() { + return static_cast(ProcessChild::current()); + } + +private: + JetpackChild mJetpack; + + DISALLOW_EVIL_CONSTRUCTORS(JetpackProcessChild); +}; + +} +} + +#endif // mozilla_jetpack_JetpackProcessChild_h diff --git a/js/jetpack/JetpackProcessParent.cpp b/js/jetpack/JetpackProcessParent.cpp new file mode 100644 index 000000000000..def56c634943 --- /dev/null +++ b/js/jetpack/JetpackProcessParent.cpp @@ -0,0 +1,61 @@ +/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Firefox. + * + * The Initial Developer of the Original Code is + * the Mozilla Foundation . + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "mozilla/jetpack/JetpackProcessParent.h" + +#include "mozilla/ipc/BrowserProcessSubThread.h" + +namespace mozilla { +namespace jetpack { + +JetpackProcessParent::JetpackProcessParent() + : mozilla::ipc::GeckoChildProcessHost(GeckoProcessType_Jetpack) +{ +} + +JetpackProcessParent::~JetpackProcessParent() +{ +} + +void +JetpackProcessParent::Launch() +{ + AsyncLaunch(); +} + +} // namespace jetpack +} // namespace mozilla diff --git a/js/jetpack/JetpackProcessParent.h b/js/jetpack/JetpackProcessParent.h new file mode 100644 index 000000000000..da62c23fe556 --- /dev/null +++ b/js/jetpack/JetpackProcessParent.h @@ -0,0 +1,76 @@ +/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Firefox. + * + * The Initial Developer of the Original Code is + * the Mozilla Foundation . + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef mozilla_jetpack_JetpackProcessParent_h +#define mozilla_jetpack_JetpackProcessParent_h + +#include "base/basictypes.h" + +#include "base/file_path.h" +#include "base/scoped_ptr.h" +#include "base/thread.h" +#include "base/waitable_event.h" +#include "chrome/common/child_process_host.h" + +#include "mozilla/ipc/GeckoChildProcessHost.h" + +namespace mozilla { +namespace jetpack { + +class JetpackProcessParent : mozilla::ipc::GeckoChildProcessHost +{ +public: + JetpackProcessParent(); + ~JetpackProcessParent(); + + /** + * Aynchronously launch the jetpack process. + */ + void Launch(); + + using mozilla::ipc::GeckoChildProcessHost::GetShutDownEvent; + using mozilla::ipc::GeckoChildProcessHost::GetChannel; + using mozilla::ipc::GeckoChildProcessHost::GetChildProcessHandle; + +private: + DISALLOW_EVIL_CONSTRUCTORS(JetpackProcessParent); +}; + +} // namespace jetpack +} // namespace mozilla + +#endif // mozilla_jetpack_JetpackProcessParent_h diff --git a/js/jetpack/JetpackService.cpp b/js/jetpack/JetpackService.cpp new file mode 100644 index 000000000000..ee197575ebc7 --- /dev/null +++ b/js/jetpack/JetpackService.cpp @@ -0,0 +1,79 @@ +/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Firefox. + * + * The Initial Developer of the Original Code is + * the Mozilla Foundation . + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "base/basictypes.h" +#include "mozilla/jetpack/JetpackService.h" + +#include "mozilla/jetpack/JetpackParent.h" +#include "nsIJetpack.h" + +#include "nsIGenericFactory.h" + +namespace mozilla { +namespace jetpack { + +NS_IMPL_ISUPPORTS1(JetpackService, + nsIJetpackService) + +NS_IMETHODIMP +JetpackService::CreateJetpack(nsIJetpack** aResult) +{ + nsRefPtr j = new JetpackParent(); + *aResult = j.forget().get(); + return NS_OK; +} + +NS_GENERIC_FACTORY_CONSTRUCTOR(JetpackService) + +} // namespace jetpack +} // namespace mozilla + +#define JETPACKSERVICE_CID \ +{ 0x4cf18fcd, 0x4247, 0x4388, \ + { 0xb1, 0x88, 0xb0, 0x72, 0x2a, 0xc0, 0x52, 0x21 } } + +static const nsModuleComponentInfo kComponents[] = { + { + "mozilla::jetpack::JetpackService", + JETPACKSERVICE_CID, + "@mozilla.org/jetpack/service;1", + mozilla::jetpack::JetpackServiceConstructor + } +}; + +NS_IMPL_NSGETMODULE(jetpack, kComponents) + diff --git a/js/jetpack/JetpackService.h b/js/jetpack/JetpackService.h new file mode 100644 index 000000000000..b30847a367ff --- /dev/null +++ b/js/jetpack/JetpackService.h @@ -0,0 +1,56 @@ +/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Firefox. + * + * The Initial Developer of the Original Code is + * the Mozilla Foundation . + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef mozilla_jetpack_JetpackService_h +#define mozilla_jetpack_JetpackService_h + +#include "nsIJetpackService.h" + +namespace mozilla { +namespace jetpack { + +class JetpackService : public nsIJetpackService +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIJETPACKSERVICE +}; + +} // jetpack +} // mozilla + +#endif // mozilla_jetpack_JetpackService_h diff --git a/js/jetpack/Makefile.in b/js/jetpack/Makefile.in new file mode 100644 index 000000000000..a95d3abe706a --- /dev/null +++ b/js/jetpack/Makefile.in @@ -0,0 +1,76 @@ +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is Mozilla Firefox. +# +# The Initial Developer of the Original Code is +# the Mozilla Foundation . +# Portions created by the Initial Developer are Copyright (C) 2010 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either the GNU General Public License Version 2 or later (the "GPL"), or +# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +DEPTH = ../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +MODULE = jetpack +LIBRARY_NAME = jetpack_s +LIBXUL_LIBRARY = 1 +FORCE_STATIC_LIB = 1 +IS_COMPONENT = 1 +EXPORT_LIBRARY = 1 +MODULE_NAME = jetpack + +XPIDLSRCS = \ + nsIJetpackService.idl \ + nsIJetpack.idl \ + $(NULL) + +EXPORTS_NAMESPACES = mozilla/jetpack +EXPORTS_mozilla/jetpack = \ + JetpackProcessChild.h \ + JetpackProcessParent.h \ + JetpackParent.h \ + JetpackChild.h \ + JetpackService.h \ + $(NULL) + +CPPSRCS = \ + JetpackParent.cpp \ + JetpackChild.cpp \ + JetpackProcessChild.cpp \ + JetpackProcessParent.cpp \ + JetpackService.cpp \ + $(NULL) + +include $(topsrcdir)/config/config.mk +include $(topsrcdir)/ipc/chromium/chromium-config.mk +include $(topsrcdir)/config/rules.mk diff --git a/js/jetpack/PJetpack.ipdl b/js/jetpack/PJetpack.ipdl new file mode 100644 index 000000000000..438a57246b80 --- /dev/null +++ b/js/jetpack/PJetpack.ipdl @@ -0,0 +1,48 @@ +/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Firefox. + * + * The Initial Developer of the Original Code is + * the Mozilla Foundation . + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +namespace mozilla { +namespace jetpack { + +async protocol PJetpack +{ +child: + async LoadImplementation(nsCString script); +}; + +} +} diff --git a/js/jetpack/ipdl.mk b/js/jetpack/ipdl.mk new file mode 100644 index 000000000000..7e95c589836f --- /dev/null +++ b/js/jetpack/ipdl.mk @@ -0,0 +1,3 @@ +IPDLSRCS = \ + PJetpack.ipdl \ + $(NULL) diff --git a/js/jetpack/nsIJetpack.idl b/js/jetpack/nsIJetpack.idl new file mode 100644 index 000000000000..68d06fcafdc4 --- /dev/null +++ b/js/jetpack/nsIJetpack.idl @@ -0,0 +1,44 @@ +/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Firefox. + * + * The Initial Developer of the Original Code is + * the Mozilla Foundation . + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "nsISupports.idl" + +[scriptable, uuid(be12cc9f-75d4-4f2d-b062-f549ea13446a)] +interface nsIJetpack : nsISupports +{ + void loadImplementation(in AString aURI); +}; diff --git a/js/jetpack/nsIJetpackService.idl b/js/jetpack/nsIJetpackService.idl new file mode 100644 index 000000000000..96cc25503c4e --- /dev/null +++ b/js/jetpack/nsIJetpackService.idl @@ -0,0 +1,46 @@ +/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Firefox. + * + * The Initial Developer of the Original Code is + * the Mozilla Foundation . + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "nsISupports.idl" + +interface nsIJetpack; + +[scriptable, uuid(2e097e3e-225f-42a3-87a8-c5c22659fef0)] +interface nsIJetpackService : nsISupports +{ + nsIJetpack createJetpack(); +}; diff --git a/toolkit/library/libxul-config.mk b/toolkit/library/libxul-config.mk index 2a7fd5f4a4a1..aca547cbebd5 100644 --- a/toolkit/library/libxul-config.mk +++ b/toolkit/library/libxul-config.mk @@ -153,6 +153,10 @@ COMPONENT_LIBS += \ appcomps \ $(NULL) +ifdef MOZ_IPC +COMPONENT_LIBS += jetpack_s +endif + ifdef BUILD_CTYPES COMPONENT_LIBS += \ jsctypes \ diff --git a/toolkit/library/nsStaticXULComponents.cpp b/toolkit/library/nsStaticXULComponents.cpp index 0ed239ebfadd..cfcda634e7da 100644 --- a/toolkit/library/nsStaticXULComponents.cpp +++ b/toolkit/library/nsStaticXULComponents.cpp @@ -137,6 +137,13 @@ #define LAYOUT_DEBUG_MODULE #endif +#ifdef MOZ_IPC +#define JETPACK_MODULES \ + MODULE(jetpack) +#else +#define JETPACK_MODULES +#endif + #ifdef MOZ_PLUGINS #define PLUGINS_MODULES \ MODULE(nsPluginModule) @@ -243,6 +250,7 @@ WIDGET_MODULES \ MODULE(nsImageLib2Module) \ ICON_MODULE \ + JETPACK_MODULES \ PLUGINS_MODULES \ MODULE(nsLayoutModule) \ MODULE(docshell_provider) \ diff --git a/toolkit/toolkit-makefiles.sh b/toolkit/toolkit-makefiles.sh index ad3010e8c675..47ef4e1913db 100644 --- a/toolkit/toolkit-makefiles.sh +++ b/toolkit/toolkit-makefiles.sh @@ -85,6 +85,7 @@ MAKEFILES_dom=" dom/src/threads/Makefile dom/locales/Makefile dom/plugins/Makefile + js/jetpack/Makefile " MAKEFILES_editor=" diff --git a/toolkit/toolkit-tiers.mk b/toolkit/toolkit-tiers.mk index 53f8f336f6b1..31faf05646ed 100644 --- a/toolkit/toolkit-tiers.mk +++ b/toolkit/toolkit-tiers.mk @@ -104,7 +104,7 @@ endif # ifdef MOZ_IPC -tier_platform_dirs += ipc +tier_platform_dirs += ipc js/jetpack endif tier_platform_dirs += \ diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index ad79f4ae4373..e51ff5ed9e25 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -743,6 +743,7 @@ nsXULAppInfo::GetWidgetToolkit(nsACString& aResult) SYNC_ENUMS(DEFAULT, Default) SYNC_ENUMS(PLUGIN, Plugin) SYNC_ENUMS(CONTENT, Content) +SYNC_ENUMS(JETPACK, Jetpack) SYNC_ENUMS(IPDLUNITTEST, IPDLUnitTest) // .. and ensure that that is all of them: diff --git a/toolkit/xre/nsEmbedFunctions.cpp b/toolkit/xre/nsEmbedFunctions.cpp index 9ef55fda0c6f..025b2560a319 100644 --- a/toolkit/xre/nsEmbedFunctions.cpp +++ b/toolkit/xre/nsEmbedFunctions.cpp @@ -89,6 +89,7 @@ #include "mozilla/ipc/ProcessChild.h" #include "ScopedXREEmbed.h" +#include "mozilla/jetpack/JetpackProcessChild.h" #include "mozilla/plugins/PluginProcessChild.h" #ifdef MOZ_IPDL_TESTS @@ -104,6 +105,7 @@ using mozilla::ipc::IOThreadChild; using mozilla::ipc::ProcessChild; using mozilla::ipc::ScopedXREEmbed; +using mozilla::jetpack::JetpackProcessChild; using mozilla::plugins::PluginProcessChild; using mozilla::startup::sChildProcessType; @@ -393,6 +395,10 @@ XRE_InitChildProcess(int aArgc, process = new PluginProcessChild(parentHandle); break; + case GeckoProcessType_Jetpack: + process = new JetpackProcessChild(parentHandle); + break; + case GeckoProcessType_IPDLUnitTest: #ifdef MOZ_IPDL_TESTS process = new IPDLUnitTestProcessChild(parentHandle); diff --git a/xpcom/build/nsXULAppAPI.h b/xpcom/build/nsXULAppAPI.h index 2c70cc679d2c..5056c5eb83df 100644 --- a/xpcom/build/nsXULAppAPI.h +++ b/xpcom/build/nsXULAppAPI.h @@ -424,6 +424,7 @@ enum GeckoProcessType { GeckoProcessType_Plugin, GeckoProcessType_Content, + GeckoProcessType_Jetpack, GeckoProcessType_IPDLUnitTest, @@ -435,6 +436,7 @@ static const char* const kGeckoProcessTypeString[] = { "default", "plugin", "tab", + "jetpack", "ipdlunittest" }; diff --git a/xpcom/system/nsIXULRuntime.idl b/xpcom/system/nsIXULRuntime.idl index f26707f7d718..39f91d61d33c 100644 --- a/xpcom/system/nsIXULRuntime.idl +++ b/xpcom/system/nsIXULRuntime.idl @@ -93,7 +93,8 @@ interface nsIXULRuntime : nsISupports const unsigned long PROCESS_TYPE_DEFAULT = 0; const unsigned long PROCESS_TYPE_PLUGIN = 1; const unsigned long PROCESS_TYPE_CONTENT = 2; - const unsigned long PROCESS_TYPE_IPDLUNITTEST = 3; + const unsigned long PROCESS_TYPE_JETPACK = 3; + const unsigned long PROCESS_TYPE_IPDLUNITTEST = 4; /** * The type of the caller's process. Returns one of the values above.