Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Member Functions | Private Attributes
nsProfileCollector::ExtensionEnumerator Class Reference
Collaboration diagram for nsProfileCollector::ExtensionEnumerator:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ExtensionEnumerator ()
nsresult Init ()
nsresult LogExtensions (nsIMetricsEventItem *extensionsItem)

Private Member Functions

already_AddRefed
< nsIMetricsEventItem
CreateExtensionItem (nsIUpdateItem *extension)

Private Attributes

nsRefPtr< nsMetricsServicemMetricsService
nsCOMPtr< nsIRDFServicemRDFService
nsCOMPtr< nsIExtensionManagermExtensionManager
nsCOMPtr< nsIRDFDataSourcemExtensionsDS
nsCOMPtr< nsIRDFResourcemDisabledResource

Detailed Description

Definition at line 92 of file nsProfileCollector.cpp.


Constructor & Destructor Documentation

Definition at line 95 of file nsProfileCollector.cpp.


Member Function Documentation

Definition at line 692 of file nsProfileCollector.cpp.

{
  nsCOMPtr<nsIMetricsEventItem> extensionItem;
  mMetricsService->CreateEventItem(NS_LITERAL_STRING("extension"),
                                   getter_AddRefs(extensionItem));
  NS_ENSURE_TRUE(extensionItem, nsnull);

  nsCOMPtr<nsIWritablePropertyBag2> properties;
  nsMetricsUtils::NewPropertyBag(getter_AddRefs(properties));
  NS_ENSURE_TRUE(properties, nsnull);

  nsString id, version;
  extension->GetId(id);
  NS_ENSURE_TRUE(!id.IsEmpty(), nsnull);

  nsCString hashedID;
  nsresult rv = mMetricsService->HashUTF16(id, hashedID);
  NS_ENSURE_SUCCESS(rv, nsnull);

  properties->SetPropertyAsACString(
      NS_LITERAL_STRING("extensionid"), hashedID);
  
  extension->GetVersion(version);
  if (!version.IsEmpty()) {
    properties->SetPropertyAsAString(NS_LITERAL_STRING("version"), version);
  }
  MS_LOG(("Logged extension extensionid=%s (hashed to %s) version=%s",
          NS_ConvertUTF16toUTF8(id).get(), hashedID.get(),
          NS_ConvertUTF16toUTF8(version).get()));

  nsCString resourceID("urn:mozilla:item:");
  resourceID.Append(NS_ConvertUTF16toUTF8(id));

  nsCOMPtr<nsIRDFResource> itemResource;
  mRDFService->GetResource(resourceID, getter_AddRefs(itemResource));
  NS_ENSURE_TRUE(itemResource, nsnull);

  nsCOMPtr<nsIRDFNode> itemDisabledNode;
  mExtensionsDS->GetTarget(itemResource, mDisabledResource, PR_TRUE,
                           getter_AddRefs(itemDisabledNode));
  nsCOMPtr<nsIRDFLiteral> itemDisabledLiteral =
    do_QueryInterface(itemDisabledNode);

  if (itemDisabledLiteral) {
    const PRUnichar *value = nsnull;
    itemDisabledLiteral->GetValueConst(&value);
    if (nsDependentString(value).Equals(NS_LITERAL_STRING("true"))) {
      properties->SetPropertyAsBool(NS_LITERAL_STRING("disabled"), PR_TRUE);
      MS_LOG(("Logged extension disabled=true"));
    }
  }

  extensionItem->SetProperties(properties);

  nsIMetricsEventItem *item = nsnull;
  extensionItem.swap(item);
  return item;
}

Here is the call graph for this function:

Definition at line 636 of file nsProfileCollector.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 659 of file nsProfileCollector.cpp.

{
  PRUint32 count = 0;
  nsIUpdateItem **extensions = nsnull;
  nsresult rv = mExtensionManager->GetItemList(nsIUpdateItem::TYPE_EXTENSION,
                                               &count, &extensions);
  NS_ENSURE_SUCCESS(rv, rv);

  if (count == 0) {
    return NS_OK;
  }
  NS_ENSURE_STATE(extensions);

  for (PRUint32 i = 0; i < count; ++i) {
    nsIUpdateItem *extension = extensions[i];
    if (!extension) {
      NS_WARNING("null extension in array");
      continue;
    }

    nsCOMPtr<nsIMetricsEventItem> item = CreateExtensionItem(extension);
    if (item) {
      extensionsItem->AppendChild(item);
    }
    NS_RELEASE(extension);
  }

  NS_Free(extensions);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 112 of file nsProfileCollector.cpp.

Definition at line 110 of file nsProfileCollector.cpp.

Definition at line 111 of file nsProfileCollector.cpp.

Definition at line 108 of file nsProfileCollector.cpp.

Definition at line 109 of file nsProfileCollector.cpp.


The documentation for this class was generated from the following file: