English 中文(简体)
我们如何能够找到一个独特的避风港?
原标题:How can we identify a unique nsHTTPChannel?

I am doing some development on the firefox both with javascript and C++ for some XPCOM components.
I am trying to monitor the http activity with nsIHttpActivityDistributor.

现在的问题是,是否存在属于<条码>的id的任何<代码>?

我想节省一些<代码>nsIHttpChannel提到C++中的物体,然后在Javascript或C++中处理。 事情是,目前我找不到一个elegent的路标,用以确定一个能够用于js和C++的频道物体,用于将其明确输入一个记录文档。

任何想法?

最佳回答

You can easily add your own data to HTTP channels, they always implement nsIPropertyBag2 and nsIWritablePropertyBag2 interfaces. Something along these lines (untested code, merely to illustrate the principle):

static PRInt64 maxChannelID = -1;

...

nsCOMPtr<nsIWritablePropertyBag2> bag = do_QueryInterface(channel);
if (!bag)
  ...

nsAutoString prop(NS_LITERAL_STRING("myChannelID"));
PRInt64 channelID;

rv = bag->GetPropertyAsInt64(prop, &channelID);
if (NS_FAILED(rv))
{
  // First time that we see that channel, assign it an ID
  channelID = ++maxChannelID;
  rv = bag->SetPropertyAsInt64(prop, channelID)
  if (NS_FAILED(rv))
    ...
}

printf("Channel ID: %i
", channelID);

不过,你可能要检查吉大港山区的情况。 我认为,在此情况下,管道财产被复制到新的渠道,并不确定这是你是否可取的。

问题回答

暂无回答




相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签