Closed Bug 970821 Opened 10 years ago Closed 10 years ago

Use an array of observer strings in ContentParent

Categories

(Core :: IPC, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla30

People

(Reporter: khuey, Assigned: lpy)

Details

(Whiteboard: [MemShrink] [mentor=jdm] [lang=c++] [good first bug])

Attachments

(1 file, 3 obsolete files)

Whiteboard: [MemShrink]
Whiteboard: [MemShrink] → [MemShrink] [mentor=jdm] [lang=c++] [good first bug]
Assignee: nobody → pylaurent1314
Attached patch bug970821.patch (obsolete) — Splinter Review
I wrote ugly "for iteration"
Attachment #8374224 - Flags: review?(josh)
Attachment #8374224 - Flags: review?(josh) → review-
Attachment #8374224 - Flags: review-
Attached patch bug970821-V2.patch (obsolete) — Splinter Review
Attachment #8374224 - Attachment is obsolete: true
Attachment #8374267 - Flags: review?(josh)
Comment on attachment 8374267 [details] [diff] [review]
bug970821-V2.patch

Review of attachment 8374267 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/ipc/ContentParent.h
@@ +590,5 @@
>      nsConsoleService* GetConsoleService();
>  
>      nsDataHashtable<nsUint64HashKey, nsCOMPtr<ParentIdleListener> > mIdleListeners;
>  
> +    nsTArray<const char*> mObserverTopics;

There's no need for a class member. Please use a static C++ array, like this:

  static const char* sObserverTopics = {
    "xpcom-shutdown",
    ...
  };
Attachment #8374267 - Flags: review?(josh) → review-
Attached patch bug970821-V2.patch (obsolete) — Splinter Review
Thank you.
Attachment #8374267 - Attachment is obsolete: true
Attachment #8374655 - Flags: review?(josh)
Comment on attachment 8374655 [details] [diff] [review]
bug970821-V2.patch

Review of attachment 8374655 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks! Please upload a new patch addressing the minor comments below. I can land it for you.

::: dom/ipc/ContentParent.cpp
@@ +672,5 @@
>      nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
>      if (obs) {
> +        for (unsigned int observerTopicIndex = 0, observerTopicLength = ArrayLength(sObserverTopics);
> +             observerTopicIndex < observerTopicLength; ++observerTopicIndex) {
> +            obs->AddObserver(this, sObserverTopics[observerTopicIndex], false);

Just use 'i' for the name of the index variable, instead of 'observerTopicIndex'.

And I wouldn't bother creating the 'observerTopicLength' variable, or I'd call it something shorter like 'length'.

@@ +1045,5 @@
>      if (obs) {
> +        for (unsigned int observerTopicIndex = 0, observerTopicLength = ArrayLength(sObserverTopics);
> +             observerTopicIndex < observerTopicLength; ++observerTopicIndex) {
> +            obs->RemoveObserver(static_cast<nsIObserver*>(this), sObserverTopics[observerTopicIndex]);
> +        }

Same here.
Attachment #8374655 - Flags: review?(josh) → review+
Thank you :)
Attachment #8374655 - Attachment is obsolete: true
Attachment #8374745 - Flags: review+
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/3a8fe7c942e3
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla30
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: