You can use the Fourier transform to get the answer.
$f(x) =
\begin{cases}
\,\,\,\,1, \hspace{1cm} 0<x\leq a\\
-1, \hspace{0.6cm} -a\leq x \leq 0
\\\,\,\,\,0, \hspace{1cm} \mathrm{otherwise}
\end{cases}\,\,$ and $\,\, F(\omega) = \frac{1}{2\pi}\int_{-\infty}^{\infty}f(x)e^{-i\omega x}dx =\frac{i(\cos a\omega -1)}{\pi \omega}$
But applying the inverse Fourier transform
$$f(x)=\int_{-\infty}^{\infty}F(\omega)e^{i\omega x}d\omega$$
On the other hand
$$ \int_{-\infty}^{\infty}F(\omega)e^{i\omega x}d\omega=\int_{-\infty}^{\infty}\frac{i(\cos a\omega -1)}{\pi \omega}e^{i\omega x}d\omega$$
$$=\int_{-\infty}^{0}\frac{i(\cos a\omega -1)}{\pi \omega}e^{i\omega x}d\omega+\int_0^{\infty}\frac{i(\cos a\omega -1)}{\pi \omega}e^{i\omega x}d\omega$$
Making change $ \omega\to-\omega$ in the first integral you get
$$f(x)=\frac{i}{\pi}\int_0^{\infty}\frac{\cos a\omega -1}{\pi \omega}(e^{i\omega x}-e^{-i\omega x})\,d\omega=-\frac{2}{\pi}\int_0^{\infty}\frac{\cos a\omega -1}{\pi \omega}\sin\omega x\,d\omega$$
Now, put $x=b$, and the desired integral
$$I=\int _0^{\infty }\frac{\cos a\omega-1}{\omega }\sin b\omega \,d\omega=-\frac{\pi}{2}\begin{cases}
\,\,\,\,1, \hspace{1cm} 0<b\leq a\\
-1, \hspace{0.6cm} -a\leq b \leq 0
\\\,\,\,\,0, \hspace{1cm} \mathrm{otherwise}
\end{cases}$$
You can also evaluate the integral directly:
$$I=\int _0^{\infty }\frac{\cos a\omega-1}{\omega }\sin b\omega \,d\omega=\int _0^{\infty }\Big(\frac{\cos a\omega\sin b\omega}{\omega }-\frac{\sin b\omega}{\omega}\Big)d\omega$$
Using $\sin x+\sin y=2\sin(\frac{x+y}{2})\cos(\frac{x-y}{2})$
$$I=\int _0^{\infty }\Big(\frac{\sin(a+b)\omega}{2\omega }+\frac{\sin(b-a)\omega}{2\omega }-\frac{\sin b\omega}{\omega}\Big)d\omega$$
Taking into consideration that $\,\int _0^{\infty }\frac{\sin cx}{x }dx=\frac{\pi}{2}sgn \,c$
$$I=\frac{\pi}{4}\big(sgn(a+b)+sgn(b-a)-2sgn \,b\big)$$
Best Answer
Hint: Use Plancherel theorem $$\int _{-\infty }^{\infty }|f(x)|^{2}\,dx=\int_{-\infty }^{\infty}|{\hat {f}}(\omega)|^{2}\,d\omega$$ then $$\int _{-1}^{1}dx=\int_{-\infty }^{\infty}\frac{4}{2\pi}\dfrac{\sin^2\omega}{\omega^2}\,d\omega$$