Changes

Jump to: navigation, search

Discussion of Using XPCOM Components

64 bytes added, 14:49, 19 November 2008
m
Cookie Manager Source
Notice that the C++ code is not named the same as the IDL. In fact, nsCookieService.cpp/h defines a single class that implements all of '''nsICookieService''' and '''nsICookieManager2''', which includes '''nsICookieManger''' through inheritance.
Why have '''nsICookieManger2'''? Why not simply add more to '''nsICookieManager'''? The nsICookieManager interface is a '''[https://developer.mozilla.org/En/Interfaces/About_Frozen_Interfaces Frozen Interface'''], which means that it is guaranteed not to change in the future, and developers can use it knowing that nothing will happen to it down the road. Any component that implements this interface must also guarantee that the method and attributes don't change their signature.
What if you need to add something? It will happen eventually. The typical answer is to add a new interface that inherits from the old one, bumping a version number by one. This explains the existence of '''nsICookieManager2''', and is a common design pattern in Mozilla.

Navigation menu