SlideShare a Scribd company logo
XPCO
M

CROSS PLATFORM COMPONENT OBJECT
MODELING
A Brief Overview
Catalogue
 Introduction
 Benefits
 Drawbacks
 Concepts
 Example

Code

 Working

 References
Introduction








XPCOM is a cross platform component object model, similar
to Microsoft COM.
It has multiple language bindings, allowing XPCOM
components to be used and implemented in JavaScript, Java,
and Python in addition to C++.
Interfaces in XPCOM are defined in a dialect of IDL
called XPIDL.
XPCOM itself provides a set of core components and
classes, e.g. file and memory management, threads, basic
data structures (strings, arrays, variants), etc.
Benefits


XPCOM components can be used by any programming
language Mozilla supports.



Objects implemented as XPCOM can be global to an
application, and are not dependent on the scope of any one
window. You can use an XPCOM service to share data
between windows.



XPCOM encourages modular programming - programming
logic can be encapsulated within a component.
Drawbacks


Objects must be accessed from their defined interfaces.
Javascript shortcuts such as the global window object cannot
be accessed.




The only exception to this rule, is if you set a magical
property wrappedJSObject on your component implemented in
JavaScript, the object this property refers to will be accessible
from the calling side. You can set ”this.wrappedJSObject =
this” in your component's constructor and avoid writing any
interfaces altogether.

It is easier to have memory leaks.
Concepts


Components:




A component is simply an object that implements interfaces, and
is registered with the component manager.

Interfaces:


Interfaces are used to define what functions and attributes an
XPCOM component provides. nsISupports is an interface that all
classes must implement. It provides a function to request the
interfaces on a class.
Concepts


Factories:




(Cont.)

Factories are objects used to instantiate components. Each
factory object implements the nsIFactory interface.

Modules:


Multiple classes can be defined in a file. A module is an object
that is used to register, unregister and provide factories for
classes. It implements the nsIModule interface.
Example Code
Example Code

(Cont.)
Example Code

(Cont.)
Working


I. Startup & Registration


During the startup process if the file compreg.dat is missing or
the file .autoreg exists, the application knows that it needs to
register components. It then loads files from each of the
components folders, including the components folder in each
extension directory. It then calls the function NSGetModule on
each file to get the object that implements the nsIModule
Interface. The module object is then used to register your

module. This is used to simplify the process of retrieving
the module later in class creation. The registerSelf function
is called to do the actual registering. When removing a
class, the unregisterSelf function is called.
Working


II. Class Creation





(Cont.)

The code calls getClassObject on your module.
This returns a class factory. The factory then has a method called
createInstance which is used to create the actual class object.

III. Accessing the component



You can now access your component by the code written.
Mozilla also provides a component construction process to easy
creation with JavaScript.
References


http://kb.mozillazine.org



http://en.wikipedia.org/wiki/XPCOM



https://developer.mozilla.org/en/docs/XPCOM



http://www.ibm.com/developerworks/webservices/library/coxpcom/index.html
Thank You
Jay Patel
(M.Sc. IT - Part 1)

More Related Content

PPTX
Visual Basic User Interface-VI
PPTX
Visual Basic –User Interface- V
PPTX
Java training
PPT
Working in Visual Studio.Net
PPTX
Architecture in .net
DOCX
.Net framework components by naveen kumar veligeti
PPTX
.Net framework architecture
PPT
Attributes & .NET components
Visual Basic User Interface-VI
Visual Basic –User Interface- V
Java training
Working in Visual Studio.Net
Architecture in .net
.Net framework components by naveen kumar veligeti
.Net framework architecture
Attributes & .NET components

What's hot (8)

PPTX
.Net framework
PPTX
Namespaces in C#
PPT
Core Java interview questions-ppt
DOCX
Interview Questions and Answers for Java
DOC
Java interview questions
PPTX
Fundamentals of oops in .Net
PDF
What's new in SObjectizer 5.5.9
PPT
Microsoft .NET Framework
.Net framework
Namespaces in C#
Core Java interview questions-ppt
Interview Questions and Answers for Java
Java interview questions
Fundamentals of oops in .Net
What's new in SObjectizer 5.5.9
Microsoft .NET Framework
Ad

Viewers also liked (13)

PPS
Tributo A The Beatles
PDF
Studi di settore ATTESTAZIONE, ASSEVERAZIONE e ASPETTI SANZIONATORI in CAPO a...
DOCX
1 consegna diagnosi certificata a scuola
PPTX
iJournalism: Putting it All Together
PDF
Modalità di prenotazione per la diagnosiaslna1
PPTX
Métodos ágiles de programación
PDF
extending-php
DOC
ARMY Education Transcript
DOC
Applied anatomy
PDF
MBA Colour
PDF
Architecting Security across global networks
PDF
Tesi: diploma alta formazione in “Psicologia dell'apprendimento della Matemat...
Tributo A The Beatles
Studi di settore ATTESTAZIONE, ASSEVERAZIONE e ASPETTI SANZIONATORI in CAPO a...
1 consegna diagnosi certificata a scuola
iJournalism: Putting it All Together
Modalità di prenotazione per la diagnosiaslna1
Métodos ágiles de programación
extending-php
ARMY Education Transcript
Applied anatomy
MBA Colour
Architecting Security across global networks
Tesi: diploma alta formazione in “Psicologia dell'apprendimento della Matemat...
Ad

Similar to Pcom xpcom (20)

PPTX
.Net framework
PPTX
Interoduction to c++
PDF
Aspect Oriented Programming Through C#.NET
PPTX
.net Based Component Technologies
PDF
Maxbox starter19
PDF
.NET TECHNOLOGIES
PPT
SynapseIndia dotnet web development architecture module
PPS
dot NET Framework
DOCX
Patterns (contd)Software Development ProcessDesign patte.docx
PPT
ActionScript 3.0 Fundamentals
DOCX
Net Interview questions
DOCX
Interview Question of Aspdotnet
PDF
Dot NET Interview Questions PDF By ScholarHat
DOCX
Online lg prodect
PPT
COM Introduction
PDF
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
PPT
Inside .net framework
PPT
Topic 1 PBO
PPTX
distributing computing
.Net framework
Interoduction to c++
Aspect Oriented Programming Through C#.NET
.net Based Component Technologies
Maxbox starter19
.NET TECHNOLOGIES
SynapseIndia dotnet web development architecture module
dot NET Framework
Patterns (contd)Software Development ProcessDesign patte.docx
ActionScript 3.0 Fundamentals
Net Interview questions
Interview Question of Aspdotnet
Dot NET Interview Questions PDF By ScholarHat
Online lg prodect
COM Introduction
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Inside .net framework
Topic 1 PBO
distributing computing

Recently uploaded (20)

PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Cloud computing and distributed systems.
PDF
cuic standard and advanced reporting.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Review of recent advances in non-invasive hemoglobin estimation
Building Integrated photovoltaic BIPV_UPV.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
MIND Revenue Release Quarter 2 2025 Press Release
Digital-Transformation-Roadmap-for-Companies.pptx
Cloud computing and distributed systems.
cuic standard and advanced reporting.pdf
Big Data Technologies - Introduction.pptx
Encapsulation_ Review paper, used for researhc scholars
MYSQL Presentation for SQL database connectivity
Understanding_Digital_Forensics_Presentation.pptx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Per capita expenditure prediction using model stacking based on satellite ima...
Dropbox Q2 2025 Financial Results & Investor Presentation
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
20250228 LYD VKU AI Blended-Learning.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Machine learning based COVID-19 study performance prediction
Review of recent advances in non-invasive hemoglobin estimation

Pcom xpcom

  • 1. XPCO M CROSS PLATFORM COMPONENT OBJECT MODELING A Brief Overview
  • 2. Catalogue  Introduction  Benefits  Drawbacks  Concepts  Example Code  Working  References
  • 3. Introduction     XPCOM is a cross platform component object model, similar to Microsoft COM. It has multiple language bindings, allowing XPCOM components to be used and implemented in JavaScript, Java, and Python in addition to C++. Interfaces in XPCOM are defined in a dialect of IDL called XPIDL. XPCOM itself provides a set of core components and classes, e.g. file and memory management, threads, basic data structures (strings, arrays, variants), etc.
  • 4. Benefits  XPCOM components can be used by any programming language Mozilla supports.  Objects implemented as XPCOM can be global to an application, and are not dependent on the scope of any one window. You can use an XPCOM service to share data between windows.  XPCOM encourages modular programming - programming logic can be encapsulated within a component.
  • 5. Drawbacks  Objects must be accessed from their defined interfaces. Javascript shortcuts such as the global window object cannot be accessed.   The only exception to this rule, is if you set a magical property wrappedJSObject on your component implemented in JavaScript, the object this property refers to will be accessible from the calling side. You can set ”this.wrappedJSObject = this” in your component's constructor and avoid writing any interfaces altogether. It is easier to have memory leaks.
  • 6. Concepts  Components:   A component is simply an object that implements interfaces, and is registered with the component manager. Interfaces:  Interfaces are used to define what functions and attributes an XPCOM component provides. nsISupports is an interface that all classes must implement. It provides a function to request the interfaces on a class.
  • 7. Concepts  Factories:   (Cont.) Factories are objects used to instantiate components. Each factory object implements the nsIFactory interface. Modules:  Multiple classes can be defined in a file. A module is an object that is used to register, unregister and provide factories for classes. It implements the nsIModule interface.
  • 11. Working  I. Startup & Registration  During the startup process if the file compreg.dat is missing or the file .autoreg exists, the application knows that it needs to register components. It then loads files from each of the components folders, including the components folder in each extension directory. It then calls the function NSGetModule on each file to get the object that implements the nsIModule Interface. The module object is then used to register your module. This is used to simplify the process of retrieving the module later in class creation. The registerSelf function is called to do the actual registering. When removing a class, the unregisterSelf function is called.
  • 12. Working  II. Class Creation    (Cont.) The code calls getClassObject on your module. This returns a class factory. The factory then has a method called createInstance which is used to create the actual class object. III. Accessing the component   You can now access your component by the code written. Mozilla also provides a component construction process to easy creation with JavaScript.